const {JSDOM, ResourceLoader} = require("jsdom");
const jsdom = require("jsdom");
const vm = require("vm");
const {performance} = require('perf_hooks');
const {CanvasRenderingContext2D} = require('canvas');
const {Buffer} = require('buffer');
const fs = require("fs");
const CSSOM = require('cssom');
const {randomUUID} = require('crypto');
const {CSSStyleDeclaration} = require("cssstyle/lib/CSSStyleDeclaration");
const http = require("./superagentHttp");
const log = require("./log");
const {boolean} = require("webidl-conversions");


const webidlConversions = require("webidl-conversions");
const oriWebidlConversionsDOMString = webidlConversions.DOMString;
webidlConversions.DOMString = (value, options = {}) => {
    options.globals = null
    return oriWebidlConversionsDOMString(value, options);
}

Object.defineProperty(String.prototype.charAt, 'value', {
    get() {
        return 1;  // 每次访问 charAt.value 都返回 1
    },
    configurable: true // 允许后续更改
})

const oriRunInContext = vm.runInContext;
vm.runInContext = function (code, contextifiedObject, options) {
    // 同时更改路径node_modules/webidl-conversions/lib/index.js的代码
    // const StringCtor = ... => const StringCtor = options.globals ? options.globals.String ? options.globals.String:String : String;
    // 不然会报错
    delete contextifiedObject.String;
    // "value" in (String.prototype.charAt)在nodeJS和浏览器中的执行结果有区别
    code = `Object.defineProperty(String.prototype.charAt, 'value', {
                get() {
                    return 1;  // 每次访问 charAt.value 都返回 1
                },
                configurable: true // 允许后续更改
            });
    ` + code;
    return oriRunInContext(code, contextifiedObject, options);
}


function randomNum(minNum, maxNum) {
    let ret;
    switch (arguments.length) {
        case 1:
            ret = parseInt((Math.random() * minNum + 1).toString(), 10);
            return parseInt(ret);
        case 2:
            ret = parseInt((Math.random() * (maxNum - minNum + 1) + minNum).toString(), 10);
            return parseInt(ret);
        default:
            return 0;
    }
}

function formateArg(arg) {
    if (arg === 'null' || arg === 'undefined') {
        arg = null;
    }
    return arg;
}

class CustomResourceLoader extends ResourceLoader {
    fetch(url, options) {
        if (!domLoad && options.element.constructor.name === 'HTMLImageElement') {
            return Promise.resolve(() => {
                return ''
            });
        }
        if (domLoad && options.element.constructor.name === 'HTMLImageElement') {
            // 加载dom后的处理
            // return super.fetch(url, options);
            return Promise.resolve(() => {
                return ''
            });
        }

        return new Promise((resolve3) => {
            resolve3(Buffer.from('', 'utf8'))
        })
    }
}


function windowConfig(window, ua, referer, traceId, productName) {
    // 根据需要重写

    // hook XMLHttpRequest
    const oriOpen = window.XMLHttpRequest.prototype.open;
    window.XMLHttpRequest.prototype.open = function (...args) {
        Object.defineProperty(this, 'method', {
            configurable: true,
            enumerable: true,
            get: function () {
                return args[0];
            }
        });

        Object.defineProperty(this, 'requestURL', {
            configurable: true,
            enumerable: true,
            get: function () {
                return args[1];
            }
        });

        oriOpen.call(this, ...args);
    };
    const oriSetRequestHeader = window.XMLHttpRequest.prototype.setRequestHeader;
    window.XMLHttpRequest.prototype.setRequestHeader = function (...args) {
        if (this.requestHeaders === undefined) {
            this.requestHeaders = {};
        }
        this.requestHeaders[args[0]] = args[1];
        const requestHeaders = this.requestHeaders;
        Object.defineProperty(this, 'requestHeaders', {
            configurable: true,
            enumerable: true,
            get: function () {
                return requestHeaders;
            }
        });
        oriSetRequestHeader.call(this, ...args);
    };
    window.XMLHttpRequest.prototype.send = function (...args) {
        Object.defineProperty(this, 'readyState', {
            configurable: true,
            enumerable: true,
            get: function () {
                return 4;
            }
        });
        !(async () => {
            this.requestHeaders['User-Agent'] = ua;
            this.requestHeaders['Origin'] = referer;
            this.requestHeaders['Referer'] = referer;
            this.requestHeaders['Sec-Fetch-Mode'] = 'cors';
            let responseText;
            try {
                responseText = await http.request(this.method, this.requestURL, this.requestHeaders, args[0], 0, 3000, false)
            } catch (err) {
                clearIntervalTimeout();
            }
            Object.defineProperty(this, 'readyState', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return 4;
                }
            });
            Object.defineProperty(this, 'status', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return 200;
                }
            });
            Object.defineProperty(this, 'responseText', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return responseText;
                }
            });
            log.info(`[${productName}][%s] XMLHttpRequest 请求: `, traceId, this.requestURL);
            log.info(`[${productName}][%s] XMLHttpRequest 请求体: `, traceId, args[0]);
            log.info(`[${productName}][%s] XMLHttpRequest 响应: `, traceId, this.responseText + ' \n');
            this.onreadystatechange();
        })();
        // oriSend.call(this, ...args);
    };


    function evalResp(jsText, node) {
        try {
            eval('window.' + jsText);
        } catch (e) {
            try {
                eval(jsText);
            } catch (err) {
                throw err;
            }
        }
        node.readyState = "complete";
        if (node.onload) {
            try {
                node.onload();
            } catch (err) {
            }
        }
    }

    const oriGetTime = Date.prototype.getTime;

    function setTs(ts) {
        Date.prototype.getTime = function () {
            return ts
        };
    }

    function genTrace(traceList) {
        const n = 1;
        let newTraceList = [];
        traceList.forEach((tr) => {
            newTraceList.push({
                "clientX": tr[0] * n,
                "clientY": tr[1] * n,
                "ts": tr[2],
                'bubbles': true,
                "type": "mousemove"
            });
        })
        newTraceList[0]["type"] = "mousedown";
        newTraceList[newTraceList.length - 1]["type"] = "mouseup";
        return newTraceList;
    }

    function evalEvents(traceList, className) {
        const firstTs = oriGetTime.call(new Date());
        traceList.forEach((e) => {
            let ele = document.getElementsByClassName(className)[0];
            const ts = firstTs + e.ts;
            setTs(ts);
            // /Users/anl/MyDesktop/tongcheng/yidun/node_modules/jsdom/lib/jsdom/living/events/Event-impl.js
            // this.isTrusted = privateData.isTrusted || false; ==> this.isTrusted = true;
            const event = new window.MouseEvent(e.type, e)
            ele.dispatchEvent(event);
        })
        Date.prototype.getTime = oriGetTime;
    }

    function actTrace(traceList, className) {
        evalEvents(traceList, className);
        Date.prototype.getTime = oriGetTime;
    }

    const oriInsertBefore = window.Element.prototype.insertBefore;
    window.Element.prototype.insertBefore = function (node, child) {
        if (node instanceof window.HTMLScriptElement && node.src) {
            log.info(`[${productName}][%s] oriInsertBefore 请求: `, traceId, node.src);
            !(async () => {
                const headers = {
                    'User-Agent': ua,
                    'Accept': '*/*',
                    'Referer': referer,
                    'Accept-Language': 'zh-CN,zh;q=0.9',
                }
                let jsText = '';
                try {
                    jsText = await http.get(node.src, headers, 0, 0, false);
                } catch (err) {
                }
                evalResp(jsText, node);
            })();
        }
        oriInsertBefore.call(this, node, child);
    }

    const oriAppendChild = window.HTMLElement.prototype.appendChild;
    window.HTMLElement.prototype.appendChild = function (child) {
        let jsText;
        if (child instanceof window.HTMLScriptElement && child.src) {
            !(async () => {
                const headers = {
                    'User-Agent': ua,
                    'Accept': 'text/html,text/javascript',
                    'Referer': referer
                }
                log.info(`[${productName}][%s] oriAppendChild 请求: `, traceId, child.src);
                try {
                    jsText = await http.get(child.src, headers, 0, 1500, false);
                } catch (err) {
                    // reject('请求超时！');
                    window.clearIntervalTimeout();
                }

                evalResp(jsText, child);

            })();
        }
        oriAppendChild.call(this, child);
    };
}

class WindowManager {
    constructor(ua, referer, htmlText, ResourceLoader, traceId, productName, windowConfigFunction, jsdomOptions) {
        this.ua = ua;
        this.referer = referer;
        this.htmlText = htmlText;
        this.ResourceLoader = ResourceLoader;
        this.traceId = traceId;
        this.productName = productName;
        this.windowConfigFunction = windowConfigFunction;
        this.jsdomOptions = jsdomOptions;
        this.window = null;
        this.jsengineTimeoutList = [];
        this.jsengineIntervalList = [];
        this.jsengineEventList = [];
        this.initEnv();
    }
    initWindow() {
        const ua = this.ua;
        const referer = this.referer;
        const htmlText = this.htmlText;
        const resourceLoader = new this.ResourceLoader({
            strictSSL: false,
            userAgent: ua,
            proxy: http.proxy
        });
        const jsdomOptions = {
            url: referer,
            referrer: referer,
            contentType: "text/html",
            includeNodeLocations: true,
            // runScripts: "dangerously",  //加上可能会报错
            // resources: "usable",
            resources: resourceLoader,
            storageQuota: 10000000,
            FetchExternalResources: ['script'],
            QuerySelector: true,
            pretendToBeVisual: true
        };

        function configWindow(window, windowManager) {
            // 影响去哪儿H5...
            if (!global.document) {
                window.Object = Object;
            }

            function isNative(name) {
                const content = ['CanvasRenderingContext2D', 'openDatabase', 'PointerEvent', 'getBattery',
                    'HTML', 'Audio', 'Notification', 'getParameter', 'getOwnPropertyDescriptor', 'getOwnPropertyNames',
                    'log', 'debug', 'info', 'stringify', 'get', 'set', 'toString', 'loadTimes', 'createElement'
                ]
                for (let i = 0; i < content.length; i++) {
                    if (name.startsWith(content[i])) {
                        return true;
                    }
                }
                return false;
            }

            const oriToString = Function.prototype.toString;
            Function.prototype.toString = function toString(func) {
                const result = oriToString.apply(this, arguments);
                if (!this.name || isNative(this.name)) {
                    return `function ${this.name ? this.name:''}() { [native code] }`
                }
                return result;
            }
            window.Function = Function;
            const oriDebug = window.console.debug;
            window.console.debug = function debug() {
                return oriDebug.apply(this, arguments);
            }
            const oriInfo = window.console.info;
            window.console.info = function info() {
                return oriInfo.apply(this, arguments);
            }
            const oriLog = window.console.log;
            window.console.log = function log() {
                return oriLog.apply(this, arguments);
            }
            window.CanvasRenderingContext2D = CanvasRenderingContext2D;
            window.scrollTo = function () {
            };
            const ctxArr = [];
            const ctxInf = [];

            function injectCanvas() {
                function random(list) {
                    let min = 0;
                    let max = list.length
                    return list[Math.floor(Math.random() * (max - min)) + min];
                }

                let rsalt = random([...Array(7).keys()].map(a => a - 3))
                let gsalt = random([...Array(7).keys()].map(a => a - 3))
                let bsalt = random([...Array(7).keys()].map(a => a - 3))
                let asalt = random([...Array(7).keys()].map(a => a - 3))

                const rawGetImageData = window.CanvasRenderingContext2D.prototype.getImageData;


                const noisifyOne = function (canvas, context) {
                    const width = canvas.width, height = canvas.height;
                    const imageData = rawGetImageData.apply(context, [0, 0, width, height]);
                    for (let i = 0; i < height; i++) {
                        for (let j = 0; j < width; j++) {
                            const n = ((i * (width * 4)) + (j * 4));
                            imageData.data[n + 0] = imageData.data[n + 0] + rsalt;
                            imageData.data[n + 1] = imageData.data[n + 1] + gsalt;
                            imageData.data[n + 2] = imageData.data[n + 2] + bsalt;
                            imageData.data[n + 3] = imageData.data[n + 3] + asalt;
                        }
                    }
                    context.putImageData(imageData, 0, 0);
                }
                const noisify = function (canvas, context, checkInfo = true) {
                    let ctxIdx = ctxArr.indexOf(context);
                    let info = ctxInf[ctxIdx];
                    if (checkInfo) {
                        if (!info.added && info.useArc || info.useFillText) {
                            noisifyOne(canvas, context);
                            info.added = true
                        }
                    } else {
                        noisifyOne(canvas, context);
                    }

                };


                (function mockGetContext() {
                    let rawGetContext = window.HTMLCanvasElement.prototype.getContext

                    Object.defineProperty(window.HTMLCanvasElement.prototype, "getContext", {
                        "value": function () {
                            let result = rawGetContext.apply(this, arguments);
                            if (arguments[0] === '2d') {
                                ctxArr.push(result)
                                ctxInf.push({})
                            }
                            return result;
                        }
                    });

                    Object.defineProperty(window.HTMLCanvasElement.prototype.constructor, "length", {
                        "value": 1
                    });

                    Object.defineProperty(window.HTMLCanvasElement.prototype.constructor, "toString", {
                        "value": () => "function getContext() { [native code] }"
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.constructor, "name", {
                        "value": "getContext"
                    });
                })();

                (function mockArc() {
                    let rawArc = window.CanvasRenderingContext2D.prototype.arc
                    Object.defineProperty(window.CanvasRenderingContext2D.prototype, "arc", {
                        "value": function () {
                            let ctxIdx = ctxArr.indexOf(this);
                            ctxInf[ctxIdx].useArc = true;
                            return rawArc.apply(this, arguments);
                        }
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.arc, "length", {
                        "value": 5
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.arc, "toString", {
                        "value": () => "function arc() { [native code] }"
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.arc, "name", {
                        "value": "arc"
                    });
                })();

                (function mockFillText() {
                    const rawFillText = window.CanvasRenderingContext2D.prototype.fillText;
                    Object.defineProperty(window.CanvasRenderingContext2D.prototype, "fillText", {
                        "value": function () {
                            let ctxIdx = ctxArr.indexOf(this);
                            ctxInf[ctxIdx].useFillText = true;
                            return rawFillText.apply(this, arguments);
                        }
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.fillText, "length", {
                        "value": 4
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.fillText, "toString", {
                        "value": () => "function fillText() { [native code] }"
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.fillText, "name", {
                        "value": "fillText"
                    });
                })();


                (function mockToBlob() {
                    const toBlob = window.HTMLCanvasElement.prototype.toBlob;

                    Object.defineProperty(window.HTMLCanvasElement.prototype, "toBlob", {
                        "value": function () {
                            noisify(this, this.getContext("2d"));
                            return toBlob.apply(this, arguments);
                        }
                    });

                    Object.defineProperty(window.HTMLCanvasElement.prototype.toBlob, "length", {
                        "value": 1
                    });

                    Object.defineProperty(window.HTMLCanvasElement.prototype.toBlob, "toString", {
                        "value": () => "function toBlob() { [native code] }"
                    });

                    Object.defineProperty(window.HTMLCanvasElement.prototype.toBlob, "name", {
                        "value": "toBlob"
                    });
                })();

                (function mockToDataURL() {
                    const toDataURL = window.HTMLCanvasElement.prototype.toDataURL;
                    Object.defineProperty(window.HTMLCanvasElement.prototype, "toDataURL", {
                        "value": function () {
                            const context = this.getContext("2d");
                            if (global.productName && global.productName === 'Akamai') {
                                noisifyOne(global.akamaiCanvas, global.akamaiContext);
                                return global.akamaiCanvas.toDataURL();
                            }
                            if (global.productName && global.productName === 'Reese84' && this.webgl) {
                                noisifyOne(global.reese84Canvas, global.reese84Context);
                                return global.reese84Canvas.toDataURL();
                            }
                            noisify(this, context);
                            const result = toDataURL.apply(this, arguments);
                            let type = 'image/png';
                            if (arguments[0] && typeof arguments[0] === 'string') {
                                type = arguments[0];
                            }
                            return `data:${type};base64,${result.split(',')[1]}`;
                            // if (context.font === '16pt Arial') {
                            //     return '';
                            // }else if(context.font === '6pt Arial') {
                            //     return '';
                            // }

                        }
                    });

                    Object.defineProperty(window.HTMLCanvasElement.prototype.toDataURL, "length", {
                        "value": 0
                    });

                    Object.defineProperty(window.HTMLCanvasElement.prototype.toDataURL, "toString", {
                        "value": () => "function toDataURL() { [native code] }"
                    });

                    Object.defineProperty(window.HTMLCanvasElement.prototype.toDataURL, "name", {
                        "value": "toDataURL"
                    });
                })();


                (function mockGetImageData() {
                    Object.defineProperty(window.CanvasRenderingContext2D.prototype, "getImageData", {
                        "value": function () {
                            noisify(this.canvas, this);
                            return rawGetImageData.apply(this, arguments);
                        }
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.getImageData, "length", {
                        "value": 4
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.getImageData, "toString", {
                        "value": () => "function getImageData() { [native code] }"
                    });

                    Object.defineProperty(window.CanvasRenderingContext2D.prototype.getImageData, "name", {
                        "value": "getImageData"
                    });
                })();
                global.hasUnjectCanvas = true;
            }

            if (!global.hasUnjectCanvas) {
                injectCanvas();
            }

            let oriNow = Date.now;
            let tsSet = null;
            Date.now = function () {
                if (tsSet) {
                    return tsSet;
                } else {
                    return oriNow();
                }
            }
            window.OriDate = Date;
            window.oriGetTime = window.OriDate.prototype.getTime;
            window.recoverTs = function () {
                Date = window.OriDate;
                tsSet = null;
            }
            window.setTs = function setTs(tsSet) {
                class MyDate extends window.OriDate {
                    constructor() {
                        super(tsSet);
                    }
                }

                if (tsSet) {
                    Date = MyDate;
                    window.Date = MyDate;
                }

            }
            const oriCreateEvent = window.document.createEvent;
            window.document.createEvent = function (type) {
                if (type === 'TouchEvent') {
                    throw new Error("Failed to execute 'createEvent' on 'Document': The provided event type ('TouchEvent') is invalid.");
                }
                return oriCreateEvent.call(this, type);
            }
            global.jsengineTimeoutList = windowManager.jsengineTimeoutList;
            global.jsengineIntervalList = windowManager.jsengineIntervalList;
            global.jsengineEventList = windowManager.jsengineEventList;
            window.jsengineEventList = windowManager.jsengineEventList;
            window.jsengineIntervalList = windowManager.jsengineIntervalList;
            window.jsengineTimeoutList = windowManager.jsengineTimeoutList;

            const oriAddEventListener = window.addEventListener;
            window.addEventListener = function (...args) {
                windowManager.jsengineEventList.push([this, args]);
                return oriAddEventListener.call(this, ...args);
            }
            window.document.addEventListener = function (...args) {
                windowManager.jsengineEventList.push([this, args]);
                return oriAddEventListener.call(this, ...args);
            }
            const OriSetInterval = setInterval;
            setInterval = function (...args) {
                const interval = OriSetInterval.call(this, ...args);
                windowManager.jsengineIntervalList.push(interval);
                return interval
            };
            window.setInterval = setInterval;

            const OriSetTimeout = setTimeout;
            setTimeout = function (...args) {
                const onTimeout = args[0];
                args[0] = function () {
                    try {
                        onTimeout();
                    }catch (e) {
                        console.error('setTimeout error', e);
                    }
                }
                const timeout = OriSetTimeout.call(this, ...args);
                windowManager.jsengineTimeoutList.push(timeout);
                return timeout
            };
            window.setTimeout = setTimeout;

            window.clearIntervalTimeout = function () {
                global.jsengineIntervalList.forEach((e) => {
                    clearInterval(e);
                })
                global.jsengineTimeoutList.forEach((e) => {
                    clearTimeout(e);
                })
                global.jsengineEventList.forEach((e) => {
                    if (e[0]) {
                        e[0].removeEventListener(...e[1]);
                    }
                })
            }

            // let myCookie = "";
            // let myCookieDict = {};
            //
            // function stringCookie(cookie) {
            //     const cookieList = [];
            //     for (let i in cookie) {
            //         cookieList.push(`${i}=${cookie[i]}`)
            //     }
            //     return cookieList.join('; ');
            // }
            if (window.document) {
                // debugger
                windowManager.setCookieJar(window, referer);
            }
            // Object.defineProperty(window.document, 'cookie', {
            //     configurable: true,
            //     get: function () {
            //         return myCookie;
            //     },
            //     set: function (value) {
            //         value = value.split(';')[0].split('=');
            //         if (value[1]) {
            //             if (value[0] === 'ctt_june') {
            //                 debugger
            //                 console.log(JSON.stringify(myCookieDict));
            //                 window.clearIntervalTimeout();
            //             }
            //             myCookieDict[value[0]] = value.slice(1).join('=');
            //         }
            //         myCookie = stringCookie(myCookieDict)
            //     }
            // });

            function getRgbString(type) {
                switch (type) {
                    case 1:
                        return `rgb(${randomNum(0, 255)}, ${randomNum(0, 255)}, ${randomNum(0, 255)})`
                    case 2:
                        const num = randomNum(0, 255);
                        return `rgb(${num}, ${num}, ${num})`
                    default:
                        return 'rgb(255, 255, 255)';
                }
            }

            const colorStyle = {
                'ActiveBorder': 'rgb(255, 255, 255)',
                'ActiveCaption': getRgbString(2),
                'AppWorkspace': 'rgb(255, 255, 255)',
                'Background': getRgbString(1),
                'ButtonFace': 'rgb(221, 221, 221)',
                'ButtonHighlight': 'rgb(221, 221, 221)',
                'ButtonShadow': 'rgb(136, 136, 136)',
                'ButtonText': 'rgb(0, 0, 0)',
                'CaptionText': 'rgb(0, 0, 0)',
                'GrayText': 'rgb(128, 128, 128)',
                'Highlight': getRgbString(1),
                'HighlightText': 'rgb(0, 0, 0)',
                'InactiveBorder': 'rgb(255, 255, 255)',
                'InactiveCaption': 'rgb(255, 255, 255)',
                'InactiveCaptionText': getRgbString(2),
                'InfoBackground': getRgbString(1),
                'InfoText': 'rgb(0, 0, 0)',
                'Menu': getRgbString(2),
                'MenuText': 'rgb(0, 0, 0)',
                'Scrollbar': 'rgb(255, 255, 255)',
                'ThreeDDarkShadow': getRgbString(2),
                'ThreeDFace': 'rgb(192, 192, 192)',
                'ThreeDHighlight': 'rgb(221, 221, 221)',
                'ThreeDLightShadow': 'rgb(192, 192, 192)',
                'ThreeDShadow': getRgbString(2),
                'Window': 'rgb(255, 255, 255)',
                'WindowFrame': 'rgb(204, 204, 204)',
                'WindowText': 'rgb(0, 0, 0)'
            };
            const oriGetComputedStyle = window.getComputedStyle;
            const styleResults = {
                "ActiveBorder": "rgb(107, 107, 107)",
                "ActiveCaption": "rgb(255, 255, 255)",
                "ActiveText": "rgb(255, 0, 0)",
                "AppWorkspace": "rgb(18, 18, 18)",
                "Background": "rgb(18, 18, 18)",
                "ButtonBorder": "rgb(107, 107, 107)",
                "ButtonFace": "rgb(107, 107, 107)",
                "ButtonHighlight": "rgb(107, 107, 107)",
                "ButtonShadow": "rgb(107, 107, 107)",
                "ButtonText": "rgb(255, 255, 255)",
                "Canvas": "rgb(18, 18, 18)",
                "CanvasText": "rgb(255, 255, 255)",
                "CaptionText": "rgb(255, 255, 255)",
                "Field": "rgb(59, 59, 59)",
                "FieldText": "rgb(255, 255, 255)",
                "GrayText": "rgb(128, 128, 128)",
                "Highlight": "rgb(181, 213, 255)",
                "HighlightText": "rgb(255, 255, 255)",
                "InactiveBorder": "rgb(107, 107, 107)",
                "InactiveCaption": "rgb(18, 18, 18)",
                "InactiveCaptionText": "rgb(128, 128, 128)",
                "InfoBackground": "rgb(18, 18, 18)",
                "InfoText": "rgb(255, 255, 255)",
                "LinkText": "rgb(0, 0, 238)",
                "Mark": "rgb(255, 255, 0)",
                "MarkText": "rgb(0, 0, 0)",
                "Menu": "rgb(18, 18, 18)",
                "MenuText": "rgb(255, 255, 255)",
                "Scrollbar": "rgb(18, 18, 18)",
                "ThreeDDarkShadow": "rgb(107, 107, 107)",
                "ThreeDFace": "rgb(107, 107, 107)",
                "ThreeDHighlight": "rgb(107, 107, 107)",
                "ThreeDLightShadow": "rgb(107, 107, 107)",
                "ThreeDShadow": "rgb(107, 107, 107)",
                "VisitedText": "rgb(85, 26, 139)",
                "Window": "rgb(18, 18, 18)",
                "WindowFrame": "rgb(107, 107, 107)",
                "WindowText": "rgb(255, 255, 255)"
            }
            Object.defineProperties(CSSStyleDeclaration.prototype, {
                cssText: {
                    get: function () {
                        var properties = [];
                        var i;
                        var name;
                        var value;
                        var priority;
                        for (i = 0; i < this._length; i++) {
                            name = this[i];
                            value = this.getPropertyValue(name);
                            priority = this.getPropertyPriority(name);
                            if (priority !== '') {
                                priority = ' !' + priority;
                            }
                            properties.push([name, ': ', value, priority, ';'].join(''));
                        }
                        return properties.join(' ');
                    },
                    set: function (value) {
                        var i;
                        this._values = {};
                        Array.prototype.splice.call(this, 0, this._length);
                        this._importants = {};
                        var dummyRule;
                        try {
                            dummyRule = CSSOM.parse('#bogus{' + value + '}').cssRules[0].style;
                        } catch (err) {
                            // malformed css, just return
                            return;
                        }
                        var rule_length = dummyRule.length;
                        var name;
                        for (i = 0; i < rule_length; ++i) {
                            name = dummyRule[i];
                            this.setProperty(
                                dummyRule[i],
                                dummyRule.getPropertyValue(name),
                                dummyRule.getPropertyPriority(name)
                            );
                        }
                        this._onChange(this.cssText);
                        if (value.startsWith('background-color: ') && value.endsWith('!important')) {
                            // Akamai检测元素rgb
                            this._values['background-color'] = value.split('background-color: ')[1].trim().split('!important')[0].trim();
                        }

                    },
                    enumerable: true,
                    configurable: true,
                },
                parentRule: {
                    get: function () {
                        return null;
                    },
                    enumerable: true,
                    configurable: true,
                },
                length: {
                    get: function () {
                        return this._length;
                    },
                    /**
                     * This deletes indices if the new length is less then the current
                     * length. If the new length is more, it does nothing, the new indices
                     * will be undefined until set.
                     **/
                    set: function (value) {
                        var i;
                        for (i = value; i < this._length; i++) {
                            delete this[i];
                        }
                        this._length = value;
                    },
                    enumerable: true,
                    configurable: true,
                },
            });
            window.getComputedStyle = function (ele) {
                const color = colorStyle[ele.style.color];
                color ? ele.style.color = color : null;

                const result = oriGetComputedStyle.call(this, ele);
                if (ele.style._values && ele.style._values['background-color']) {
                    // Akamai检测元素rgb
                    result.backgroundColor = styleResults[ele.style._values['background-color']]
                }
                return result;
            }

            window.RTCPeerConnection = function () {
            };

            class DOMStringList extends Array {
                contains(v) {
                    for (const valueElement of this) {
                        if (valueElement === v) {
                            return true
                        }
                    }
                    return false
                }
            }

            window.DOMStringList = DOMStringList;

            class IDBRequest {
                constructor(source, transaction) {
                    this.source = source
                    this.transaction = transaction
                    this.error = null
                    this.onerror = null
                    this.readyState = "pending"
                    this.result = null
                }

            }

            Object.defineProperty(IDBRequest.prototype, 'onsuccess', {
                set: function (callback) {
                    const event = {
                        isTrusted: true, target: this,
                        srcElement: this, type: 'success', currentTarget: this
                    }
                    this.readyState = 'done'
                    callback(event)
                }
            })

            class IDBObjectStore {
                constructor(name, keyPath) {
                    this.name = name
                    this.keyPath = keyPath
                    this.autoIncrement = false
                    this.indexNames = new DOMStringList()
                    this.table = {}
                }

                get(name) {
                    const iDBRequest = new IDBRequest(this, this.transaction);
                    iDBRequest.rerult = {name: name, value: this.table[name]}
                    return iDBRequest;
                }

                put(item, key = null) {
                    let value;
                    if (!key) {
                        key = item[this.keyPath];
                        value = item.value;
                    } else {
                        value = item;
                    }
                    const iDBRequest = new IDBRequest(this, this.transaction);
                    this.table[key] = value;
                    iDBRequest.readyState = 'done';
                    return iDBRequest;
                }
            }

            class IDBTransaction {
                constructor(db, names) {
                    this.names = names;
                    this.db = db;
                    this.durability = 'default';
                    this.error = null;
                    this.mode = 'readonly';
                    this.objectStoreNames = db.objectStoreNames;
                }

                objectStore(name) {
                    const objectStore = this.db.objectStoreS[name];
                    objectStore.transaction = this;
                    return objectStore;
                }
            }


            class IDBDatabase {
                constructor(name, version) {
                    this.name = name;
                    this.objectStoreNames = new DOMStringList();
                    this.version = version;
                    this.objectStoreS = {};
                }

                transaction(names, opt = null) {
                    return new IDBTransaction(this, names);
                }

                close() {
                }

                createObjectStore(name, options) {
                    for (let i = 0; i < this.objectStoreNames.length; i++) {
                        if (name === this.objectStoreNames[i]) {
                            return this.objectStoreS[name];
                        }
                    }
                    this.objectStoreS[name] = new IDBObjectStore(name, options.keyPath);
                    this.objectStoreNames.push(name)
                    return this.objectStoreS[name];
                }

            }

            class IDBOpenDBRequest {
                constructor() {
                    this.readyState = "pending";
                    this.result = null;
                    this.returnValue = true;
                }
            }

            Object.defineProperty(IDBOpenDBRequest.prototype, 'onupgradeneeded', {
                set: function (callback) {
                    const event = {
                        isTrusted: true, target: this,
                        srcElement: this, type: 'success', currentTarget: this
                    }
                    this.readyState = "done";
                    this.target = this;
                    callback(event)
                }
            })
            Object.defineProperty(IDBOpenDBRequest.prototype, 'onsuccess', {
                set: function (callback) {
                    const event = {
                        isTrusted: true, target: this,
                        srcElement: this, type: 'success', currentTarget: this
                    }
                    this.readyState = "done";
                    callback(event)
                }
            })
            window.iDBmap = {};

            class IDBFactory {
                cmp() {
                }

                async databases() {
                    debugger
                    return [];
                }

                deleteDatabase(name) {
                    return new IDBOpenDBRequest(name, 1);
                }

                open(name, version) {
                    const k = `${name}-${version}`;
                    let db = null;
                    db = window.iDBmap[k];
                    if (!db) {
                        db = new IDBDatabase(name, version);
                        window.iDBmap[k] = db;
                    }
                    const dbRequest = new IDBOpenDBRequest();
                    dbRequest.result = db;
                    return dbRequest
                }
            }

            window.indexedDB = new IDBFactory();

            // 若为2则易盾验证不过
            // window.devicePixelRatio = devicePixelRatio;
            window.openDatabase = function openDatabase() {
            }

            // Akamai
            class SpeechSynthesisVoice {
                constructor(...args) {
                    this.default = args[0]
                    this.lang = args[1]
                    this.localService = args[2]
                    this.name = args[3]
                    this.voiceURI = args[4]
                }
            }

            class SpeechSynthesis {
                onvoiceschanged() {
                }

                paused = false
                pending = false
                speaking = false

                getVoices() {
                    const voices = [{
                        "default": true,
                        "lang": "zh-CN",
                        "localService": true,
                        "name": "Tingting",
                        "voiceURI": "Tingting"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Albert",
                        "voiceURI": "Albert"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Alice",
                        "voiceURI": "Alice"
                    }, {
                        "default": false,
                        "lang": "sv-SE",
                        "localService": true,
                        "name": "Alva",
                        "voiceURI": "Alva"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Amélie",
                        "voiceURI": "Amélie"
                    }, {
                        "default": false,
                        "lang": "ms-MY",
                        "localService": true,
                        "name": "Amira",
                        "voiceURI": "Amira"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Anna",
                        "voiceURI": "Anna"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Bad News",
                        "voiceURI": "Bad News"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Bahh",
                        "voiceURI": "Bahh"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Bells",
                        "voiceURI": "Bells"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Boing",
                        "voiceURI": "Boing"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Bubbles",
                        "voiceURI": "Bubbles"
                    }, {
                        "default": false,
                        "lang": "he-IL",
                        "localService": true,
                        "name": "Carmit",
                        "voiceURI": "Carmit"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Cellos",
                        "voiceURI": "Cellos"
                    }, {
                        "default": false,
                        "lang": "id-ID",
                        "localService": true,
                        "name": "Damayanti",
                        "voiceURI": "Damayanti"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Daniel",
                        "voiceURI": "Daniel"
                    }, {
                        "default": false,
                        "lang": "bg-BG",
                        "localService": true,
                        "name": "Daria",
                        "voiceURI": "Daria"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Wobble",
                        "voiceURI": "Wobble"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Eddy (德语（德国）)",
                        "voiceURI": "Eddy (德语（德国）)"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Eddy (英语（英国）)",
                        "voiceURI": "Eddy (英语（英国）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Eddy (英语（美国）)",
                        "voiceURI": "Eddy (英语（美国）)"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Eddy (西班牙语（西班牙）)",
                        "voiceURI": "Eddy (西班牙语（西班牙）)"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Eddy (西班牙语（墨西哥）)",
                        "voiceURI": "Eddy (西班牙语（墨西哥）)"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Eddy (芬兰语（芬兰）)",
                        "voiceURI": "Eddy (芬兰语（芬兰）)"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Eddy (法语（加拿大）)",
                        "voiceURI": "Eddy (法语（加拿大）)"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Eddy (法语（法国）)",
                        "voiceURI": "Eddy (法语（法国）)"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Eddy (意大利语（意大利）)",
                        "voiceURI": "Eddy (意大利语（意大利）)"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Eddy (葡萄牙语（巴西）)",
                        "voiceURI": "Eddy (葡萄牙语（巴西）)"
                    }, {
                        "default": false,
                        "lang": "nl-BE",
                        "localService": true,
                        "name": "Ellen",
                        "voiceURI": "Ellen"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Flo (德语（德国）)",
                        "voiceURI": "Flo (德语（德国）)"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Flo (英语（英国）)",
                        "voiceURI": "Flo (英语（英国）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Flo (英语（美国）)",
                        "voiceURI": "Flo (英语（美国）)"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Flo (西班牙语（西班牙）)",
                        "voiceURI": "Flo (西班牙语（西班牙）)"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Flo (西班牙语（墨西哥）)",
                        "voiceURI": "Flo (西班牙语（墨西哥）)"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Flo (芬兰语（芬兰）)",
                        "voiceURI": "Flo (芬兰语（芬兰）)"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Flo (法语（加拿大）)",
                        "voiceURI": "Flo (法语（加拿大）)"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Flo (法语（法国）)",
                        "voiceURI": "Flo (法语（法国）)"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Flo (意大利语（意大利）)",
                        "voiceURI": "Flo (意大利语（意大利）)"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Flo (葡萄牙语（巴西）)",
                        "voiceURI": "Flo (葡萄牙语（巴西）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Fred",
                        "voiceURI": "Fred"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Good News",
                        "voiceURI": "Good News"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Grandma (德语（德国）)",
                        "voiceURI": "Grandma (德语（德国）)"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Grandma (英语（英国）)",
                        "voiceURI": "Grandma (英语（英国）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Grandma (英语（美国）)",
                        "voiceURI": "Grandma (英语（美国）)"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Grandma (西班牙语（西班牙）)",
                        "voiceURI": "Grandma (西班牙语（西班牙）)"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Grandma (西班牙语（墨西哥）)",
                        "voiceURI": "Grandma (西班牙语（墨西哥）)"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Grandma (芬兰语（芬兰）)",
                        "voiceURI": "Grandma (芬兰语（芬兰）)"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Grandma (法语（加拿大）)",
                        "voiceURI": "Grandma (法语（加拿大）)"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Grandma (法语（法国）)",
                        "voiceURI": "Grandma (法语（法国）)"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Grandma (意大利语（意大利）)",
                        "voiceURI": "Grandma (意大利语（意大利）)"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Grandma (葡萄牙语（巴西）)",
                        "voiceURI": "Grandma (葡萄牙语（巴西）)"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Grandpa (德语（德国）)",
                        "voiceURI": "Grandpa (德语（德国）)"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Grandpa (英语（英国）)",
                        "voiceURI": "Grandpa (英语（英国）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Grandpa (英语（美国）)",
                        "voiceURI": "Grandpa (英语（美国）)"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Grandpa (西班牙语（西班牙）)",
                        "voiceURI": "Grandpa (西班牙语（西班牙）)"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Grandpa (西班牙语（墨西哥）)",
                        "voiceURI": "Grandpa (西班牙语（墨西哥）)"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Grandpa (芬兰语（芬兰）)",
                        "voiceURI": "Grandpa (芬兰语（芬兰）)"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Grandpa (法语（加拿大）)",
                        "voiceURI": "Grandpa (法语（加拿大）)"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Grandpa (法语（法国）)",
                        "voiceURI": "Grandpa (法语（法国）)"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Grandpa (意大利语（意大利）)",
                        "voiceURI": "Grandpa (意大利语（意大利）)"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Grandpa (葡萄牙语（巴西）)",
                        "voiceURI": "Grandpa (葡萄牙语（巴西）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Jester",
                        "voiceURI": "Jester"
                    }, {
                        "default": false,
                        "lang": "ro-RO",
                        "localService": true,
                        "name": "Ioana",
                        "voiceURI": "Ioana"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Jacques",
                        "voiceURI": "Jacques"
                    }, {
                        "default": false,
                        "lang": "pt-PT",
                        "localService": true,
                        "name": "Joana",
                        "voiceURI": "Joana"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Junior",
                        "voiceURI": "Junior"
                    }, {
                        "default": false,
                        "lang": "th-TH",
                        "localService": true,
                        "name": "Kanya",
                        "voiceURI": "Kanya"
                    }, {
                        "default": false,
                        "lang": "en-AU",
                        "localService": true,
                        "name": "Karen",
                        "voiceURI": "Karen"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Kathy",
                        "voiceURI": "Kathy"
                    }, {
                        "default": false,
                        "lang": "ja-JP",
                        "localService": true,
                        "name": "Kyoko",
                        "voiceURI": "Kyoko"
                    }, {
                        "default": false,
                        "lang": "hr-HR",
                        "localService": true,
                        "name": "Lana",
                        "voiceURI": "Lana"
                    }, {
                        "default": false,
                        "lang": "sk-SK",
                        "localService": true,
                        "name": "Laura",
                        "voiceURI": "Laura"
                    }, {
                        "default": false,
                        "lang": "hi-IN",
                        "localService": true,
                        "name": "Lekha",
                        "voiceURI": "Lekha"
                    }, {
                        "default": false,
                        "lang": "uk-UA",
                        "localService": true,
                        "name": "Lesya",
                        "voiceURI": "Lesya"
                    }, {
                        "default": false,
                        "lang": "vi-VN",
                        "localService": true,
                        "name": "Linh",
                        "voiceURI": "Linh"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Luciana",
                        "voiceURI": "Luciana"
                    }, {
                        "default": false,
                        "lang": "ar-001",
                        "localService": true,
                        "name": "Majed",
                        "voiceURI": "Majed"
                    }, {
                        "default": false,
                        "lang": "hu-HU",
                        "localService": true,
                        "name": "Tünde",
                        "voiceURI": "Tünde"
                    }, {
                        "default": false,
                        "lang": "zh-TW",
                        "localService": true,
                        "name": "美嘉",
                        "voiceURI": "美嘉"
                    }, {
                        "default": false,
                        "lang": "el-GR",
                        "localService": true,
                        "name": "Melina",
                        "voiceURI": "Melina"
                    }, {
                        "default": false,
                        "lang": "ru-RU",
                        "localService": true,
                        "name": "Milena",
                        "voiceURI": "Milena"
                    }, {
                        "default": false,
                        "lang": "en-IE",
                        "localService": true,
                        "name": "Moira",
                        "voiceURI": "Moira"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Mónica",
                        "voiceURI": "Mónica"
                    }, {
                        "default": false,
                        "lang": "ca-ES",
                        "localService": true,
                        "name": "Montse",
                        "voiceURI": "Montse"
                    }, {
                        "default": false,
                        "lang": "nb-NO",
                        "localService": true,
                        "name": "Nora",
                        "voiceURI": "Nora"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Organ",
                        "voiceURI": "Organ"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Paulina",
                        "voiceURI": "Paulina"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Superstar",
                        "voiceURI": "Superstar"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Ralph",
                        "voiceURI": "Ralph"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Reed (德语（德国）)",
                        "voiceURI": "Reed (德语（德国）)"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Reed (英语（英国）)",
                        "voiceURI": "Reed (英语（英国）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Reed (英语（美国）)",
                        "voiceURI": "Reed (英语（美国）)"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Reed (西班牙语（西班牙）)",
                        "voiceURI": "Reed (西班牙语（西班牙）)"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Reed (西班牙语（墨西哥）)",
                        "voiceURI": "Reed (西班牙语（墨西哥）)"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Reed (芬兰语（芬兰）)",
                        "voiceURI": "Reed (芬兰语（芬兰）)"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Reed (法语（加拿大）)",
                        "voiceURI": "Reed (法语（加拿大）)"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Reed (意大利语（意大利）)",
                        "voiceURI": "Reed (意大利语（意大利）)"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Reed (葡萄牙语（巴西）)",
                        "voiceURI": "Reed (葡萄牙语（巴西）)"
                    }, {
                        "default": false,
                        "lang": "en-IN",
                        "localService": true,
                        "name": "Rishi",
                        "voiceURI": "Rishi"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Rocko (德语（德国）)",
                        "voiceURI": "Rocko (德语（德国）)"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Rocko (英语（英国）)",
                        "voiceURI": "Rocko (英语（英国）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Rocko (英语（美国）)",
                        "voiceURI": "Rocko (英语（美国）)"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Rocko (西班牙语（西班牙）)",
                        "voiceURI": "Rocko (西班牙语（西班牙）)"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Rocko (西班牙语（墨西哥）)",
                        "voiceURI": "Rocko (西班牙语（墨西哥）)"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Rocko (芬兰语（芬兰）)",
                        "voiceURI": "Rocko (芬兰语（芬兰）)"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Rocko (法语（加拿大）)",
                        "voiceURI": "Rocko (法语（加拿大）)"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Rocko (法语（法国）)",
                        "voiceURI": "Rocko (法语（法国）)"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Rocko (意大利语（意大利）)",
                        "voiceURI": "Rocko (意大利语（意大利）)"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Rocko (葡萄牙语（巴西）)",
                        "voiceURI": "Rocko (葡萄牙语（巴西）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Samantha",
                        "voiceURI": "Samantha"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Sandy (德语（德国）)",
                        "voiceURI": "Sandy (德语（德国）)"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Sandy (英语（英国）)",
                        "voiceURI": "Sandy (英语（英国）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Sandy (英语（美国）)",
                        "voiceURI": "Sandy (英语（美国）)"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Sandy (西班牙语（西班牙）)",
                        "voiceURI": "Sandy (西班牙语（西班牙）)"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Sandy (西班牙语（墨西哥）)",
                        "voiceURI": "Sandy (西班牙语（墨西哥）)"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Sandy (芬兰语（芬兰）)",
                        "voiceURI": "Sandy (芬兰语（芬兰）)"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Sandy (法语（加拿大）)",
                        "voiceURI": "Sandy (法语（加拿大）)"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Sandy (法语（法国）)",
                        "voiceURI": "Sandy (法语（法国）)"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Sandy (意大利语（意大利）)",
                        "voiceURI": "Sandy (意大利语（意大利）)"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Sandy (葡萄牙语（巴西）)",
                        "voiceURI": "Sandy (葡萄牙语（巴西）)"
                    }, {
                        "default": false,
                        "lang": "da-DK",
                        "localService": true,
                        "name": "Sara",
                        "voiceURI": "Sara"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Satu",
                        "voiceURI": "Satu"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": true,
                        "name": "Shelley (德语（德国）)",
                        "voiceURI": "Shelley (德语（德国）)"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": true,
                        "name": "Shelley (英语（英国）)",
                        "voiceURI": "Shelley (英语（英国）)"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Shelley (英语（美国）)",
                        "voiceURI": "Shelley (英语（美国）)"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": true,
                        "name": "Shelley (西班牙语（西班牙）)",
                        "voiceURI": "Shelley (西班牙语（西班牙）)"
                    }, {
                        "default": false,
                        "lang": "es-MX",
                        "localService": true,
                        "name": "Shelley (西班牙语（墨西哥）)",
                        "voiceURI": "Shelley (西班牙语（墨西哥）)"
                    }, {
                        "default": false,
                        "lang": "fi-FI",
                        "localService": true,
                        "name": "Shelley (芬兰语（芬兰）)",
                        "voiceURI": "Shelley (芬兰语（芬兰）)"
                    }, {
                        "default": false,
                        "lang": "fr-CA",
                        "localService": true,
                        "name": "Shelley (法语（加拿大）)",
                        "voiceURI": "Shelley (法语（加拿大）)"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Shelley (法语（法国）)",
                        "voiceURI": "Shelley (法语（法国）)"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": true,
                        "name": "Shelley (意大利语（意大利）)",
                        "voiceURI": "Shelley (意大利语（意大利）)"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": true,
                        "name": "Shelley (葡萄牙语（巴西）)",
                        "voiceURI": "Shelley (葡萄牙语（巴西）)"
                    }, {
                        "default": false,
                        "lang": "zh-HK",
                        "localService": true,
                        "name": "善怡",
                        "voiceURI": "善怡"
                    }, {
                        "default": false,
                        "lang": "en-ZA",
                        "localService": true,
                        "name": "Tessa",
                        "voiceURI": "Tessa"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": true,
                        "name": "Thomas",
                        "voiceURI": "Thomas"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Trinoids",
                        "voiceURI": "Trinoids"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Whisper",
                        "voiceURI": "Whisper"
                    }, {
                        "default": false,
                        "lang": "nl-NL",
                        "localService": true,
                        "name": "Xander",
                        "voiceURI": "Xander"
                    }, {
                        "default": false,
                        "lang": "tr-TR",
                        "localService": true,
                        "name": "Yelda",
                        "voiceURI": "Yelda"
                    }, {
                        "default": false,
                        "lang": "ko-KR",
                        "localService": true,
                        "name": "Yuna",
                        "voiceURI": "Yuna"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": true,
                        "name": "Zarvox",
                        "voiceURI": "Zarvox"
                    }, {
                        "default": false,
                        "lang": "pl-PL",
                        "localService": true,
                        "name": "Zosia",
                        "voiceURI": "Zosia"
                    }, {
                        "default": false,
                        "lang": "cs-CZ",
                        "localService": true,
                        "name": "Zuzana",
                        "voiceURI": "Zuzana"
                    }, {
                        "default": false,
                        "lang": "de-DE",
                        "localService": false,
                        "name": "Google Deutsch",
                        "voiceURI": "Google Deutsch"
                    }, {
                        "default": false,
                        "lang": "en-US",
                        "localService": false,
                        "name": "Google US English",
                        "voiceURI": "Google US English"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": false,
                        "name": "Google UK English Female",
                        "voiceURI": "Google UK English Female"
                    }, {
                        "default": false,
                        "lang": "en-GB",
                        "localService": false,
                        "name": "Google UK English Male",
                        "voiceURI": "Google UK English Male"
                    }, {
                        "default": false,
                        "lang": "es-ES",
                        "localService": false,
                        "name": "Google español",
                        "voiceURI": "Google español"
                    }, {
                        "default": false,
                        "lang": "es-US",
                        "localService": false,
                        "name": "Google español de Estados Unidos",
                        "voiceURI": "Google español de Estados Unidos"
                    }, {
                        "default": false,
                        "lang": "fr-FR",
                        "localService": false,
                        "name": "Google français",
                        "voiceURI": "Google français"
                    }, {
                        "default": false,
                        "lang": "hi-IN",
                        "localService": false,
                        "name": "Google हिन्दी",
                        "voiceURI": "Google हिन्दी"
                    }, {
                        "default": false,
                        "lang": "id-ID",
                        "localService": false,
                        "name": "Google Bahasa Indonesia",
                        "voiceURI": "Google Bahasa Indonesia"
                    }, {
                        "default": false,
                        "lang": "it-IT",
                        "localService": false,
                        "name": "Google italiano",
                        "voiceURI": "Google italiano"
                    }, {
                        "default": false,
                        "lang": "ja-JP",
                        "localService": false,
                        "name": "Google 日本語",
                        "voiceURI": "Google 日本語"
                    }, {
                        "default": false,
                        "lang": "ko-KR",
                        "localService": false,
                        "name": "Google 한국의",
                        "voiceURI": "Google 한국의"
                    }, {
                        "default": false,
                        "lang": "nl-NL",
                        "localService": false,
                        "name": "Google Nederlands",
                        "voiceURI": "Google Nederlands"
                    }, {
                        "default": false,
                        "lang": "pl-PL",
                        "localService": false,
                        "name": "Google polski",
                        "voiceURI": "Google polski"
                    }, {
                        "default": false,
                        "lang": "pt-BR",
                        "localService": false,
                        "name": "Google português do Brasil",
                        "voiceURI": "Google português do Brasil"
                    }, {
                        "default": false,
                        "lang": "ru-RU",
                        "localService": false,
                        "name": "Google русский",
                        "voiceURI": "Google русский"
                    }, {
                        "default": false,
                        "lang": "zh-CN",
                        "localService": false,
                        "name": "Google 普通话（中国大陆）",
                        "voiceURI": "Google 普通话（中国大陆）"
                    }, {
                        "default": false,
                        "lang": "zh-HK",
                        "localService": false,
                        "name": "Google 粤語（香港）",
                        "voiceURI": "Google 粤語（香港）"
                    }, {
                        "default": false,
                        "lang": "zh-TW",
                        "localService": false,
                        "name": "Google 國語（臺灣）",
                        "voiceURI": "Google 國語（臺灣）"
                    }];
                    const newVoices = [];
                    voices.forEach((item) => {
                        newVoices.push(new SpeechSynthesisVoice(item.default, item.lang, item.localService,
                            item.name, item.voiceURI))
                    })
                    return newVoices;
                }
            }

            window.speechSynthesis = new SpeechSynthesis();

            window.DeviceOrientationEvent = function () {
            }

            window.DeviceMotionEvent = function () {
            }

            class MimeType {
                constructor(type, suffixes, description, enabledPlugin = null) {
                    if (enabledPlugin) {
                        this.enabledPlugin = enabledPlugin;
                    }
                    this.type = type;
                    this.suffixes = suffixes;
                    this.description = description;
                }
            }


            function createPdfPlugin(name) {
                const pluginP = ['application/pdf', "text/pdf"];

                class Plugin extends Array {
                }

                const plugin = new Plugin();
                pluginP.forEach((p) => {
                    Object.setPrototypeOf(plugin, Object.assign(Object.getPrototypeOf(plugin), {
                        'push': plugin.push,
                        'name': name,
                        'filename': 'internal-pdf-viewer',
                        'description': 'Portable Document Format',
                        'application/pdf': new MimeType('application/pdf', 'pdf', 'Portable Document Format', plugin),
                        'text/pdf': new MimeType('text/pdf', 'pdf', 'Portable Document Format', plugin)
                    }));
                    const mimeType = new MimeType(p, 'pdf', 'Portable Document Format', plugin);
                    plugin.push(mimeType);
                })
                return plugin;
            }

            function getPdfPlugins() {
                const pluginNames = ["PDF Viewer", "Chrome PDF Viewer", "Chromium PDF Viewer", "Microsoft Edge PDF Viewer", "WebKit built-in PDF"]
                const plugins = [];
                pluginNames.forEach((name) => {
                    const plugin = createPdfPlugin(name);
                    plugins.push(plugin);
                    plugins[name] = plugin;
                })
                return plugins
            }

            const plugins = getPdfPlugins();
            plugins.__proto__.item = function (i) {
                if (i > plugins.length) {
                    i = 0;
                }
                return this[i]
            }
            Object.defineProperty(plugins.item, 'name', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return 'item';
                }
            });

            plugins.__proto__.namedItem = function (i) {
            }
            Object.defineProperty(plugins.namedItem, 'name', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return 'namedItem';
                }
            });

            plugins.__proto__.refresh = function () {
            }
            Object.defineProperty(plugins.refresh, 'name', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return 'refresh';
                }
            });

            window.PointerEvent = function PointerEvent() {
            };
            window.PointerEvent.prototype.getPredictedEvents = function () {

            }

            class Permissions {
                async query(item) {
                    if (item.name === 'geolocation' || item.name === 'notifications' || item.name === 'camera'
                        || item.name === 'microphone' || item.name === 'durable-storage' || item.name === 'persistent-storage'
                        || item.name === 'clipboard-read' || item.name === 'audio_capture'
                    ) {
                        return {name: item.name.replace('-', '_'), state: 'prompt'};
                    } else if (item.name === 'push') {
                        throw  Error('Uncaught (in promise) DOMException: Failed to execute \'query\' on \'Permissions\': Push Permission without userVisibleOnly:true isn\'t supported yet.\n');
                    } else if (item.name === 'midi' || item.name === 'background-sync' || item.name === 'accelerometer'
                        || item.name === 'gyroscope' || item.name === 'magnetometer' || item.name === 'clipboard-write'
                        || item.name === 'payment-handler' || item.name === 'sensors') {
                        return {name: item.name.replace('-', '_'), state: 'granted'};
                    } else if (item.name === 'speaker' || item.name === 'device-info' || item.name === 'bluetooth'
                        || item.name === 'clipboard' || item.name === 'video-capture') {
                        throw Error(`Uncaught (in promise) TypeError: Failed to execute \'query\' on \'Permissions\': Failed to read the \'name\' property from \'PermissionDescriptor\': The provided value \'${item.name}\' is not a valid enum value of type PermissionName.`);
                    } else if (item.name === 'accessibility-events' || item.name === 'ambient-light-sensor') {
                        throw Error('Uncaught (in promise) TypeError: Failed to execute \'query\' on \'Permissions\': Accessibility Object Model is not enabled.');
                    }
                    return {name: item.name.replace('-', '_'), state: 'prompt'};

                }
            }

            const storageQuota = 596797540000 + randomNum(0, 10592);

            class BatteryManager {
                constructor() {
                    this.charging = boolean(randomNum(0, 1));
                    this.chargingTime = randomNum(1000, 29460);
                    this.dischargingTime = Infinity;
                    this.level = randomNum(10, 100) / 100;
                    this.onchargingchange = null;
                    this.onchargingtimechange = null;
                    this.ondischargingtimechange = null;
                    this.onlevelchange = null;
                }
            }

            class DeprecatedStorageQuota {
                queryUsageAndQuota(successCallback, failureCallback) {
                    successCallback(0, storageQuota);
                }

                requestQuota() {
                    debugger;
                }
            }

            class Navigator {
                constructor() {
                    this.appCodeName = "Mozilla";
                    this.appName = "Netscape";
                    this.appVersion = ua.split('Mozilla/')[1];
                    this.bluetooth = {};
                    this.hardwareConcurrency = 12;
                    this.clipboard = {};
                    this.connection = {
                        downlink: 10,
                        effectiveType: "4g",
                        onchange: null,
                        rtt: 50,
                        saveData: false
                    };
                    this.cookieEnabled = true;
                    this.credentials = {};
                    this.deviceMemory = 8;
                    this.doNotTrack = null;
                    this.geolocation = {};
                    this.hid = {};
                    this.ink = {};
                    this.serviceWorker = {
                        controller: null,
                        oncontrollerchange: '',
                        onmessage: null,
                        onmessageerror: null
                    }
                    this.keyboard = {};
                    this.language = "zh-CN";
                    this.languages = ["zh-CN", "zh"];
                    // this.language = "en-US";
                    // this.languages = ['en-US'];
                    this.locks = {};
                    this.managed = {};
                    this.maxTouchPoints = 0;
                    this.onLine = true;
                    this.pdfViewerEnabled = true;
                    this.platform = "MacIntel";
                    this.product = "Gecko";
                    this.productSub = "20030107";
                    this.userAgent = ua;
                    this.vendor = ua.indexOf('Chrome') !== -1 ? "Google Inc." : 'MacIntel';
                    this.vendorSub = "";
                    this.wakeLock = {};
                    this.storage = {
                        estimate: async function () {
                            return {"quota": storageQuota, "usage": 0, "usageDetails": {}}
                        }
                    };
                    this.webkitPersistentStorage = new DeprecatedStorageQuota();
                    this.webkitTemporaryStorage = new DeprecatedStorageQuota();
                    this.permissions = new Permissions();
                    this.webdriver = false;
                    this.xr = {};
                    this.mimeTypes = [];
                }
            }

            Object.setPrototypeOf(Navigator, Object.assign(Navigator.prototype, {
                javaEnabled: function () {
                    return false
                },
                vibrate: function () {
                },
                getGamepads: function () {
                },
                mediaDevices: function () {
                },
                registerProtocolHandler: function () {
                },
                requestMediaKeySystemAccess: function () {
                },
                sendBeacon: function () {
                },
                getBattery: async function getBattery() {
                    return new BatteryManager()
                }
            }));

            class AudioWorklet {
            }

            window.AudioWorklet = AudioWorklet;

            class AudioDestinationNode {
                constructor(context) {
                    this.channelCount = 2;
                    this.channelCountMode = "explicit";
                    this.channelInterpretation = "speakers";
                    this.context = context;
                    this.maxChannelCount = 2;
                    this.numberOfInputs = 1;
                    this.numberOfOutputs = 0;
                }

            }

            window.AudioDestinationNode = AudioDestinationNode;

            class AudioParam {
                constructor(value) {
                    this.automationRate = 'a-rate';
                    this.defaultValue = 0;
                    this.maxValue = 3.4028234663852886e+38;
                    this.minValue = -3.4028234663852886e+38;
                    this.value = value;
                }

            }

            window.AudioParam = AudioParam;

            class AudioListener {
                constructor() {
                    this.forwardX = new AudioParam(0);
                    this.forwardY = new AudioParam(0);
                    this.forwardZ = new AudioParam(-1);
                    this.positionX = new AudioParam(0);
                    this.positionY = new AudioParam(0);
                    this.positionZ = new AudioParam(0);
                    this.upX = new AudioParam(0);
                    this.upY = new AudioParam(1);
                    this.upZ = new AudioParam(0);
                }
            }

            window.AudioListener = AudioListener;

            class GainNode {
                constructor(context) {
                    this.channelCount = 2;
                    this.channelCountMode = 'max';
                    this.channelInterpretation = 'speakers';
                    this.context = context;
                    this.gain = context.listener.upY;
                    this.numberOfInputs = 1;
                    this.numberOfOutputs = 1;
                }
            }

            class AnalyserNode {
                constructor(context) {
                    this.channelCount = 2;
                    this.channelCountMode = 'max';
                    this.channelInterpretation = 'speakers';
                    this.context = context;
                    this.fftSize = 2048;
                    this.frequencyBinCount = 1024;
                    this.maxDecibels = -30;
                    this.minDecibels = -100;
                    this.numberOfInputs = 1;
                    this.numberOfOutputs = 1;
                    this.smoothingTimeConstant = 0.8;
                }
            }

            window.AudioContext = class AudioContext {
                constructor() {
                    this.audioWorklet = new AudioWorklet();
                    this.baseLatency = 0.005333333333333333;
                    this.currentTime = 0;
                    this.destination = new AudioDestinationNode(this);
                    this.listener = new AudioListener();
                    this.onsinkchange = null;
                    this.onstatechange = null;
                    this.outputLatency = 0;
                    this.sampleRate = 48000;
                    this.sinkId = '';
                    this.state = 'suspended';
                }

                createGain() {
                    return new GainNode(this);
                }

                createAnalyser() {
                    return new AnalyserNode(this);
                }

                createScriptProcessor() {
                    return new AudioDestinationNode(this);
                }
            };
            window.AudioContext.prototype.close = function () {
            };
            window.AudioContext.prototype.createMediaStreamTrackSource = function () {
            };
            // [0.005333333333333333, 0, 48000, 'suspended', 2, 1, 0, 2, 'explicit', 'speakers', 2048, 1024, -100, -30, 0.8, 1, 1, 2, 'max', 'speakers']

            window.Notification = function Notification() {
            };
            window.matchMedia = (str) => {
                return {
                    matches: true,
                    media: str,
                    onchange: null
                }
            };

            delete window.SharedArrayBuffer;

            AudioParam.prototype.setValueAtTime = function (...args) {
                return this;
            }
            AudioParam.prototype.setTargetAtTime = function (...args) {
                return this;
            }
            AudioParam.prototype.setValueCurveAtTime = function (...args) {
                return this;
            }
            window.AudioParam = AudioParam;

            class OscillatorNode {
                constructor(...args) {
                    this.channelCount = 2;
                    this.channelCountMode = 'max';
                    this.channelInterpretation = 'speakers';
                    this.detune = new AudioParam();
                    this.frequency = new AudioParam();
                    this.numberOfInputs = 0;
                    this.numberOfOutputs = 1;
                    this.type = 'sine';
                }
            }

            OscillatorNode.prototype.connect = function (...args) {
            };
            OscillatorNode.prototype.start = function (...args) {
            };
            OscillatorNode.prototype.disconnect = function (...args) {
            };

            window.OscillatorNode = OscillatorNode;


            class DynamicsCompressorNode {
                constructor(...args) {
                    this.attack = new AudioParam();
                    this.channelCount = 2;
                    this.channelCountMode = 'clamped-max';
                    this.channelInterpretation = 'speakers';
                    this.knee = new AudioParam();
                    this.numberOfInputs = 1;
                    this.numberOfOutputs = 1;
                    this.ratio = new AudioParam();
                    this.reduction = 0;
                    this.release = new AudioParam();
                    this.threshold = new AudioParam()
                }
            }

            DynamicsCompressorNode.prototype.connect = function (...args) {
            }
            DynamicsCompressorNode.prototype.disconnect = function (...args) {
            }

            window.DynamicsCompressorNode = DynamicsCompressorNode;

            class OfflineAudioCompletionEvent {
                constructor() {
                    this.isTrusted = true;
                    this.cancelBubble = true;
                    this.cancelable = false;
                    this.composed = false;
                    this.currentTarget = {};
                    this.defaultPrevented = false;
                    this.eventPhase = 2;
                    this.renderedBuffer = new AudioBuffer();
                    this.returnValue = true;
                    this.srcElement = {};
                    this.target = {};
                    this.timeStamp = 5532.20000000298;
                    this.type = 'complete';
                }
            }

            window.OfflineAudioCompletionEvent = OfflineAudioCompletionEvent;

            class OfflineAudioContext {
                constructor(...args) {
                    this.audioWorklet = new AudioWorklet();
                    this.currentTime = 0;
                    this.destination = {
                        channelCount: 1,
                        channelCountMode: 'explicit',
                        channelInterpretation: 'speakers',
                        maxChannelCount: 1,
                        numberOfInputs: 1,
                        numberOfOutputs: 0
                    };
                    this.length = 44100;
                    this.sampleRate = 44100;
                    this.state = 'suspended';
                }
            }

            class AudioBuffer {
                constructor(...args) {
                    this.duration = 1;
                    this.length = 44100;
                    this.numberOfChannels = 1;
                    this.sampleRate = 44100;
                }
            }

            const dataArray = JSON.parse(fs.readFileSync(require.resolve('./audioBuffer.json'), 'utf-8'));
            AudioBuffer.prototype.getChannelData = function (...args) {
                return new Float32Array(dataArray);
            };
            window.AudioBuffer = AudioBuffer;

            let offlineAudioContextOncomplete;
            Object.defineProperty(OfflineAudioContext.prototype, 'oncomplete', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return offlineAudioContextOncomplete;
                },
                set: function (value) {
                    offlineAudioContextOncomplete = value;
                    setTimeout(function () {
                        offlineAudioContextOncomplete(new OfflineAudioCompletionEvent());
                    }, 0)
                }
            });
            OfflineAudioContext.prototype.createOscillator = function (...args) {

                return new OscillatorNode();
            }
            OfflineAudioContext.prototype.createDynamicsCompressor = function (...args) {
                return new DynamicsCompressorNode();
            }
            OfflineAudioContext.prototype.startRendering = function (...args) {
            }
            window.OfflineAudioContext = OfflineAudioContext;

            const navigator1 = new Navigator();
            const navigatorPluginsGet = function () {
                return plugins;
            }
            navigatorPluginsGet.toString = function () {
                return 'function get plugins() { [native code] }';
            }
            Object.defineProperty(navigator1, 'plugins', {
                get: navigatorPluginsGet
            })
            const navigator = Object.create(navigator1);
            // const navigator = navigator1;
            window.clientInformation = navigator;

            Object.defineProperty(window, 'navigator', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return navigator;
                }
            });

            const screen1 = {
                availHeight: 1023,
                availLeft: 0,
                availTop: 38,
                availWidth: 1728,
                colorDepth: 30,
                height: 1117,
                isExtended: false,
                onchange: null,
                orientation: {
                    angle: 0,
                    onchange: null,
                    type: 'landscape-primary',
                },
                pixelDepth: 30,
                width: 1728,
            };
            const screen = Object.create(screen1);
            Object.defineProperty(window, 'screen', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return screen;
                }
            });
            window.innerHeight = 1023;
            window.outerHeight = window.innerHeight;
            window.innerWidth = 1728;
            window.outerWidth = window.innerWidth;
            Object.defineProperty(window.document.body, 'clientHeight', {
                get: function () {
                    return 15530;
                }
            })
            Object.defineProperty(window.document.body, 'clientWidth', {
                get: function () {
                    return 1697;
                }
            })
            // window.outerWidth = window.innerWidth;

            // global.location = {};
            // location.host = referer.split('//')[1].split('/')[0];
            // location.hostname = location.host;
            // location.href = referer;
            // location.protocol = referer.split('//')[0];
            // location.origin = location.protocol + '//' + location.host;
            // location.pathname = referer.split(location.host)[1];
            // Object.defineProperty(window, 'location', {
            //     configurable: true,
            //     enumerable: true,
            //     get: function () {
            //         return location;
            //     }
            // });

            // window.reload = function (){};

            const performanceEntries = [];
            // 模拟的 window.performance 对象

            const customPerformance = {
                eventCounts: {size: performanceEntries.length},
                memory: {jsHeapSizeLimit: 4294705152, totalJSHeapSize: 229653088, usedJSHeapSize: 216601668},
                navigation: {redirectCount: 0, type: 1},
                onresourcetimingbufferfull: null,
                timeOrigin: performance.timeOrigin,     // 模拟 performance.timeOrigin
                timing: {
                    connectEnd: new window.Date().getTime(),
                    connectStart: new window.Date().getTime() + randomNum(100, 200),
                    domComplete: new window.Date().getTime() + randomNum(200, 300),
                    domContentLoadedEventEnd: new window.Date().getTime() + randomNum(100, 300),
                    domContentLoadedEventStart: new window.Date().getTime() + randomNum(0, 100),
                    domInteractive: new window.Date().getTime() + randomNum(0, 100),
                    domLoading: new window.Date().getTime() + randomNum(0, 50),
                    domainLookupEnd: new window.Date().getTime() + randomNum(100, 200),
                    domainLookupStart: new window.Date().getTime() + randomNum(0, 100),
                    fetchStart: new window.Date().getTime() + randomNum(0, 100),
                    loadEventEnd: new window.Date().getTime() + randomNum(100, 200),
                    loadEventStart: new window.Date().getTime() + randomNum(0, 100),
                    navigationStart: new window.Date().getTime() + randomNum(0, 50),
                    redirectEnd: 0,
                    redirectStart: 0,
                    requestStart: new window.Date().getTime() + randomNum(0, 100),
                    responseEnd: new window.Date().getTime() + randomNum(300, 400),
                    responseStart: new window.Date().getTime() + randomNum(200, 300),
                    secureConnectionStart: new window.Date().getTime() + randomNum(0, 100),
                    unloadEventEnd: new window.Date().getTime() + randomNum(100, 200),
                    unloadEventStart: new window.Date().getTime() + randomNum(0, 100),
                }
            };

            const customPerformancePrototype = {
                now: performance.now.bind(performance), // 模拟 performance.now()
                // 模拟 mark 方法，将标记记录到 performanceEntries 数组中
                getEntries: function () {
                    return performanceEntries;
                },
                mark: function (name) {
                    const entry = {
                        name,
                        entryType: 'mark',
                        startTime: this.now(),
                        duration: 0
                    };
                    performanceEntries.push(entry);
                },

                // 模拟 measure 方法
                measure: function (name, startMark, endMark) {
                    const start = performanceEntries.find(entry => entry.name === startMark && entry.entryType === 'mark');
                    const end = performanceEntries.find(entry => entry.name === endMark && entry.entryType === 'mark');

                    if (start && end) {
                        const entry = {
                            name,
                            entryType: 'measure',
                            startTime: start.startTime,
                            duration: end.startTime - start.startTime
                        };
                        performanceEntries.push(entry);
                    } else {
                        console.warn('Invalid start or end mark for measure.');
                    }
                },

                // 模拟 getEntriesByName 方法，根据名称查找条目
                getEntriesByName: function (name, type) {
                    if (type) {
                        return performanceEntries.filter(entry => entry.name === name && entry.entryType === type);
                    }
                    return performanceEntries.filter(entry => entry.name === name);
                },

                // 模拟 clearMarks 和 clearMeasures 方法
                clearMarks: function (name) {
                    if (name) {
                        for (let i = performanceEntries.length - 1; i >= 0; i--) {
                            if (performanceEntries[i].entryType === 'mark' && performanceEntries[i].name === name) {
                                performanceEntries.splice(i, 1);
                            }
                        }
                    } else {
                        for (let i = performanceEntries.length - 1; i >= 0; i--) {
                            if (performanceEntries[i].entryType === 'mark') {
                                performanceEntries.splice(i, 1);
                            }
                        }
                    }
                },

                clearMeasures: function (name) {
                    if (name) {
                        for (let i = performanceEntries.length - 1; i >= 0; i--) {
                            if (performanceEntries[i].entryType === 'measure' && performanceEntries[i].name === name) {
                                performanceEntries.splice(i, 1);
                            }
                        }
                    } else {
                        for (let i = performanceEntries.length - 1; i >= 0; i--) {
                            if (performanceEntries[i].entryType === 'measure') {
                                performanceEntries.splice(i, 1);
                            }
                        }
                    }
                }
            }
            Object.setPrototypeOf(customPerformance, customPerformancePrototype);

            Object.defineProperty(window, 'performance', {
                configurable: true,
                get: function () {
                    return customPerformance;
                }
            })

            class PerformanceNavigationTiming {
                constructor(name, initiatorType) {
                    const startTime = window.performance.now();
                    const duration = 277.6999999284744 + randomNum(100, 300);
                    this.connectEnd = startTime;
                    this.connectStart = startTime;
                    this.decodedBodySize = 0;
                    this.domainLookupEnd = startTime;
                    this.domainLookupStart = startTime;
                    this.duration = duration;
                    this.encodedBodySize = 61872;
                    this.entryType = "resource";
                    this.fetchStart = startTime;
                    this.initiatorType = initiatorType;
                    this.name = name;
                    this.nextHopProtocol = "h2";
                    this.redirectEnd = 0;
                    this.redirectStart = 0;
                    this.renderBlockingStatus = "non-blocking";
                    this.requestStart = startTime;
                    this.responseEnd = this.startTime + this.duration;
                    this.responseStart = startTime;
                    this.responseStatus = 0;
                    this.secureConnectionStart = startTime;
                    this.serverTiming = [];
                    this.startTime = startTime;
                    this.transferSize = 62172;
                    this.workerStart = 0;
                }
            }

            window.PerformanceNavigationTiming = PerformanceNavigationTiming;
            window.history.scrollRestoration = 'auto';
            Object.defineProperty(window.history, 'length', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return randomNum(1, 10);
                }
            });

            class MySpeechSynthesis {
                constructor() {
                    this.onvoiceschanged = null
                    this.paused = false
                    this.pending = false
                    this.speaking = false
                }

                onvoiceschanged() {
                }
            }

            class WebGLShader {
                constructor(props) {
                }
            }

            window.WebGLShader = WebGLShader;

            class WebGLBuffer {
                constructor(props) {
                }
            }

            window.WebGLBuffer = WebGLBuffer;

            class WebGLProgram {
                constructor(props) {
                }
            }

            window.WebGLProgram = WebGLProgram;
            const webGLRenderingContextData = {
                ACTIVE_ATTRIBUTES: 35721,
                ACTIVE_TEXTURE: 34016,
                ACTIVE_UNIFORMS: 35718,
                ALIASED_LINE_WIDTH_RANGE: 33902,
                ALIASED_POINT_SIZE_RANGE: 33901,
                ALPHA: 6406,
                ALPHA_BITS: 3413,
                ALWAYS: 519,
                ARRAY_BUFFER: 34962,
                ARRAY_BUFFER_BINDING: 34964,
                ATTACHED_SHADERS: 35717,
                BACK: 1029,
                BLEND: 3042,
                BLEND_COLOR: 32773,
                BLEND_DST_ALPHA: 32970,
                BLEND_DST_RGB: 32968,
                BLEND_EQUATION: 32777,
                BLEND_EQUATION_ALPHA: 34877,
                BLEND_EQUATION_RGB: 32777,
                BLEND_SRC_ALPHA: 32971,
                BLEND_SRC_RGB: 32969,
                BLUE_BITS: 3412,
                BOOL: 35670,
                BOOL_VEC2: 35671,
                BOOL_VEC3: 35672,
                BOOL_VEC4: 35673,
                BROWSER_DEFAULT_WEBGL: 37444,
                BUFFER_SIZE: 34660,
                BUFFER_USAGE: 34661,
                BYTE: 5120,
                CCW: 2305,
                CLAMP_TO_EDGE: 33071,
                COLOR_ATTACHMENT0: 36064,
                COLOR_BUFFER_BIT: 16384,
                COLOR_CLEAR_VALUE: 3106,
                COLOR_WRITEMASK: 3107,
                COMPILE_STATUS: 35713,
                COMPRESSED_TEXTURE_FORMATS: 34467,
                CONSTANT_ALPHA: 32771,
                CONSTANT_COLOR: 32769,
                CONTEXT_LOST_WEBGL: 37442,
                CULL_FACE: 2884,
                CULL_FACE_MODE: 2885,
                CURRENT_PROGRAM: 35725,
                CURRENT_VERTEX_ATTRIB: 34342,
                CW: 2304,
                DECR: 7683,
                DECR_WRAP: 34056,
                DELETE_STATUS: 35712,
                DEPTH_ATTACHMENT: 36096,
                DEPTH_BITS: 3414,
                DEPTH_BUFFER_BIT: 256,
                DEPTH_CLEAR_VALUE: 2931,
                DEPTH_COMPONENT: 6402,
                DEPTH_COMPONENT16: 33189,
                DEPTH_FUNC: 2932,
                DEPTH_RANGE: 2928,
                DEPTH_STENCIL: 34041,
                DEPTH_STENCIL_ATTACHMENT: 33306,
                DEPTH_TEST: 2929,
                DEPTH_WRITEMASK: 2930,
                DITHER: 3024,
                DONT_CARE: 4352,
                DST_ALPHA: 772,
                DST_COLOR: 774,
                DYNAMIC_DRAW: 35048,
                ELEMENT_ARRAY_BUFFER: 34963,
                ELEMENT_ARRAY_BUFFER_BINDING: 34965,
                EQUAL: 514,
                FASTEST: 4353,
                FLOAT: 5126,
                FLOAT_MAT2: 35674,
                FLOAT_MAT3: 35675,
                FLOAT_MAT4: 35676,
                FLOAT_VEC2: 35664,
                FLOAT_VEC3: 35665,
                FLOAT_VEC4: 35666,
                FRAGMENT_SHADER: 35632,
                FRAMEBUFFER: 36160,
                FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 36049,
                FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 36048,
                FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 36051,
                FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 36050,
                FRAMEBUFFER_BINDING: 36006,
                FRAMEBUFFER_COMPLETE: 36053,
                FRAMEBUFFER_INCOMPLETE_ATTACHMENT: 36054,
                FRAMEBUFFER_INCOMPLETE_DIMENSIONS: 36057,
                FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: 36055,
                FRAMEBUFFER_UNSUPPORTED: 36061,
                FRONT: 1028,
                FRONT_AND_BACK: 1032,
                FRONT_FACE: 2886,
                FUNC_ADD: 32774,
                FUNC_REVERSE_SUBTRACT: 32779,
                FUNC_SUBTRACT: 32778,
                GENERATE_MIPMAP_HINT: 33170,
                GEQUAL: 518,
                GREATER: 516,
                GREEN_BITS: 3411,
                HIGH_FLOAT: 36338,
                HIGH_INT: 36341,
                IMPLEMENTATION_COLOR_READ_FORMAT: 35739,
                IMPLEMENTATION_COLOR_READ_TYPE: 35738,
                INCR: 7682,
                INCR_WRAP: 34055,
                INT: 5124,
                INT_VEC2: 35667,
                INT_VEC3: 35668,
                INT_VEC4: 35669,
                INVALID_ENUM: 1280,
                INVALID_FRAMEBUFFER_OPERATION: 1286,
                INVALID_OPERATION: 1282,
                INVALID_VALUE: 1281,
                INVERT: 5386,
                KEEP: 7680,
                LEQUAL: 515,
                LESS: 513,
                LINEAR: 9729,
                LINEAR_MIPMAP_LINEAR: 9987,
                LINEAR_MIPMAP_NEAREST: 9985,
                LINES: 1,
                LINE_LOOP: 2,
                LINE_STRIP: 3,
                LINE_WIDTH: 2849,
                LINK_STATUS: 35714,
                LOW_FLOAT: 36336,
                LOW_INT: 36339,
                LUMINANCE: 6409,
                LUMINANCE_ALPHA: 6410,
                MAX_COMBINED_TEXTURE_IMAGE_UNITS: 35661,
                MAX_CUBE_MAP_TEXTURE_SIZE: 34076,
                MAX_FRAGMENT_UNIFORM_VECTORS: 36349,
                MAX_RENDERBUFFER_SIZE: 34024,
                MAX_TEXTURE_IMAGE_UNITS: 34930,
                MAX_TEXTURE_SIZE: 3379,
                MAX_VARYING_VECTORS: 36348,
                MAX_VERTEX_ATTRIBS: 34921,
                MAX_VERTEX_TEXTURE_IMAGE_UNITS: 35660,
                MAX_VERTEX_UNIFORM_VECTORS: 36347,
                MAX_VIEWPORT_DIMS: 3386,
                MEDIUM_FLOAT: 36337,
                MEDIUM_INT: 36340,
                MIRRORED_REPEAT: 33648,
                NEAREST: 9728,
                NEAREST_MIPMAP_LINEAR: 9986,
                NEAREST_MIPMAP_NEAREST: 9984,
                NEVER: 512,
                NICEST: 4354,
                NONE: 0,
                NOTEQUAL: 517,
                NO_ERROR: 0,
                ONE: 1,
                ONE_MINUS_CONSTANT_ALPHA: 32772,
                ONE_MINUS_CONSTANT_COLOR: 32770,
                ONE_MINUS_DST_ALPHA: 773,
                ONE_MINUS_DST_COLOR: 775,
                ONE_MINUS_SRC_ALPHA: 771,
                ONE_MINUS_SRC_COLOR: 769,
                OUT_OF_MEMORY: 1285,
                PACK_ALIGNMENT: 3333,
                POINTS: 0,
                POLYGON_OFFSET_FACTOR: 32824,
                POLYGON_OFFSET_FILL: 32823,
                POLYGON_OFFSET_UNITS: 10752,
                RED_BITS: 3410,
                RENDERBUFFER: 36161,
                RENDERBUFFER_ALPHA_SIZE: 36179,
                RENDERBUFFER_BINDING: 36007,
                RENDERBUFFER_BLUE_SIZE: 36178,
                RENDERBUFFER_DEPTH_SIZE: 36180,
                RENDERBUFFER_GREEN_SIZE: 36177,
                RENDERBUFFER_HEIGHT: 36163,
                RENDERBUFFER_INTERNAL_FORMAT: 36164,
                RENDERBUFFER_RED_SIZE: 36176,
                RENDERBUFFER_STENCIL_SIZE: 36181,
                RENDERBUFFER_WIDTH: 36162,
                RENDERER: 7937,
                REPEAT: 10497,
                REPLACE: 7681,
                RGB: 6407,
                RGB5_A1: 32855,
                RGB565: 36194,
                RGBA: 6408,
                RGBA4: 32854,
                SAMPLER_2D: 35678,
                SAMPLER_CUBE: 35680,
                SAMPLES: 32937,
                SAMPLE_ALPHA_TO_COVERAGE: 32926,
                SAMPLE_BUFFERS: 32936,
                SAMPLE_COVERAGE: 32928,
                SAMPLE_COVERAGE_INVERT: 32939,
                SAMPLE_COVERAGE_VALUE: 32938,
                SCISSOR_BOX: 3088,
                SCISSOR_TEST: 3089,
                SHADER_TYPE: 35663,
                SHADING_LANGUAGE_VERSION: 35724,
                SHORT: 5122,
                SRC_ALPHA: 770,
                SRC_ALPHA_SATURATE: 776,
                SRC_COLOR: 768,
                STATIC_DRAW: 35044,
                STENCIL_ATTACHMENT: 36128,
                STENCIL_BACK_FAIL: 34817,
                STENCIL_BACK_FUNC: 34816,
                STENCIL_BACK_PASS_DEPTH_FAIL: 34818,
                STENCIL_BACK_PASS_DEPTH_PASS: 34819,
                STENCIL_BACK_REF: 36003,
                STENCIL_BACK_VALUE_MASK: 36004,
                STENCIL_BACK_WRITEMASK: 36005,
                STENCIL_BITS: 3415,
                STENCIL_BUFFER_BIT: 1024,
                STENCIL_CLEAR_VALUE: 2961,
                STENCIL_FAIL: 2964,
                STENCIL_FUNC: 2962,
                STENCIL_INDEX8: 36168,
                STENCIL_PASS_DEPTH_FAIL: 2965,
                STENCIL_PASS_DEPTH_PASS: 2966,
                STENCIL_REF: 2967,
                STENCIL_TEST: 2960,
                STENCIL_VALUE_MASK: 2963,
                STENCIL_WRITEMASK: 2968,
                STREAM_DRAW: 35040,
                SUBPIXEL_BITS: 3408,
                TEXTURE: 5890,
                TEXTURE0: 33984,
                TEXTURE1: 33985,
                TEXTURE2: 33986,
                TEXTURE3: 33987,
                TEXTURE4: 33988,
                TEXTURE5: 33989,
                TEXTURE6: 33990,
                TEXTURE7: 33991,
                TEXTURE8: 33992,
                TEXTURE9: 33993,
                TEXTURE10: 33994,
                TEXTURE11: 33995,
                TEXTURE12: 33996,
                TEXTURE13: 33997,
                TEXTURE14: 33998,
                TEXTURE15: 33999,
                TEXTURE16: 34000,
                TEXTURE17: 34001,
                TEXTURE18: 34002,
                TEXTURE19: 34003,
                TEXTURE20: 34004,
                TEXTURE21: 34005,
                TEXTURE22: 34006,
                TEXTURE23: 34007,
                TEXTURE24: 34008,
                TEXTURE25: 34009,
                TEXTURE26: 34010,
                TEXTURE27: 34011,
                TEXTURE28: 34012,
                TEXTURE29: 34013,
                TEXTURE30: 34014,
                TEXTURE31: 34015,
                TEXTURE_2D: 3553,
                TEXTURE_BINDING_2D: 32873,
                TEXTURE_BINDING_CUBE_MAP: 34068,
                TEXTURE_CUBE_MAP: 34067,
                TEXTURE_CUBE_MAP_NEGATIVE_X: 34070,
                TEXTURE_CUBE_MAP_NEGATIVE_Y: 34072,
                TEXTURE_CUBE_MAP_NEGATIVE_Z: 34074,
                TEXTURE_CUBE_MAP_POSITIVE_X: 34069,
                TEXTURE_CUBE_MAP_POSITIVE_Y: 34071,
                TEXTURE_CUBE_MAP_POSITIVE_Z: 34073,
                TEXTURE_MAG_FILTER: 10240,
                TEXTURE_MIN_FILTER: 10241,
                TEXTURE_WRAP_S: 10242,
                TEXTURE_WRAP_T: 10243,
                TRIANGLES: 4,
                TRIANGLE_FAN: 6,
                TRIANGLE_STRIP: 5,
                UNPACK_ALIGNMENT: 3317,
                UNPACK_COLORSPACE_CONVERSION_WEBGL: 37443,
                UNPACK_FLIP_Y_WEBGL: 37440,
                UNPACK_PREMULTIPLY_ALPHA_WEBGL: 37441,
                UNSIGNED_BYTE: 5121,
                UNSIGNED_INT: 5125,
                UNSIGNED_SHORT: 5123,
                UNSIGNED_SHORT_4_4_4_4: 32819,
                UNSIGNED_SHORT_5_5_5_1: 32820,
                UNSIGNED_SHORT_5_6_5: 33635,
                VALIDATE_STATUS: 35715,
                VENDOR: 7936,
                VERSION: 7938,
                VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 34975,
                VERTEX_ATTRIB_ARRAY_ENABLED: 34338,
                VERTEX_ATTRIB_ARRAY_NORMALIZED: 34922,
                VERTEX_ATTRIB_ARRAY_POINTER: 34373,
                VERTEX_ATTRIB_ARRAY_SIZE: 34339,
                VERTEX_ATTRIB_ARRAY_STRIDE: 34340,
                VERTEX_ATTRIB_ARRAY_TYPE: 34341,
                VERTEX_SHADER: 35633,
                VIEWPORT: 2978,
                ZERO: 0,
                isEnabled: function (value) {
                    switch (value) {
                        case 2960:
                            return false
                    }
                    return false
                },
                getShaderPrecisionFormat: function (value1, value2) {
                    let result = {precision: 23, rangeMax: 127, rangeMin: 127};
                    if (value1 === 35632) {
                        if (value2 === 36341 || value2 === 36340 || value2 === 36339) {
                            result = {rangeMin: 31, rangeMax: 30, precision: 0};
                        } else {
                            result = {rangeMin: 127, rangeMax: 127, precision: 23};
                        }
                    } else if (value1 === 35633) {
                        if (value2 === 36341 || value2 === 36340 || value2 === 36339) {
                            result = {rangeMin: 31, rangeMax: 30, precision: 0};
                        } else {
                            result = {rangeMin: 127, rangeMax: 127, precision: 23};
                        }
                    }
                    return result;
                },
                createBuffer: function () {
                    return new window.WebGLBuffer();
                },
                bindBuffer: function () {
                    return undefined
                },
                bufferData: function (target, size, usage) {
                    return undefined
                },
                createProgram: function () {
                    return new window.WebGLProgram();
                },
                createShader: function () {
                    return new window.WebGLShader();
                },
                shaderSource: function () {
                    return undefined
                },
                readPixels: function () {
                    return undefined
                },
                getProgramParameter: function (program, pname) {
                    return true
                },
                getParameter: function (...args) {
                    switch (args[0]) {
                        case 34047:
                            return 16;
                        case 3413:
                            return 8;
                        case 37445:
                            return 'Google Inc. (ATI Technologies Inc.)';
                        // return 'Google Inc. (Apple)';
                        case 37446:
                            return 'ANGLE (ATI Technologies Inc., AMD Radeon Pro 555X OpenGL Engine, OpenGL 4.1 ATI-4.6.20)';
                        // return 'ANGLE (Apple, Apple M2 Max, OpenGL 4.1)';
                        case 7936:
                            return 'WebKit'
                        case 7937:
                            return 'WebKit WebGL'
                        case 34852:
                            return 8;
                        case 36347:
                            return 1024;
                        case 3386:
                            return new Int32Array([16384, 16384]);
                        case 34921:
                            return 16;
                        case 35724:
                            return 'WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)';
                        case 7938:
                            return 'WebGL 1.0 (OpenGL ES 2.0 Chromium)';
                        case 36348:
                            return 31;
                        case 33901:
                            return new Float32Array([1, 64]);
                        case 32937:
                            return 4;
                        case 35661:
                            return 32;
                        case 34930:
                            return 16;
                        case 36349:
                            return 1024;
                        case 33902:
                            return new Float32Array([1, 1]);
                        case 34024:
                            return 16384;
                        case 35660:
                            return 16;
                        case 2968:
                            return 2147483647;
                        case 3379:
                            return 16384;
                        case 34076:
                            return 16384;
                        case 3412:
                            return 8;
                        case 3414:
                            return 24;
                        case 3411:
                            return 8;
                        case 3410:
                            return 8;
                        case 3415:
                            return 0;
                    }
                    debugger;
                    return 8
                },
                compileShader: function () {
                    return undefined
                },
                _ader: function () {
                    return undefined
                },

                getShaderParameter: function (shader, pname) {
                    return true;
                },

                getAttribLocation: function () {
                    return undefined
                },
                attachShader: function () {
                    return undefined
                },
                linkProgram: function () {
                    return undefined
                },
                useProgram: function () {
                    return undefined
                },
                getUniformLocation: function () {
                    return undefined
                },
                enableVertexAttribArray: function () {
                    return undefined
                },
                vertexAttribPointer: function () {
                    return undefined
                },
                uniform2f: function () {
                    return undefined
                },
                drawArrays: function () {
                    return undefined
                },
                getSupportedExtensions: function () {
                    return ["ANGLE_instanced_arrays", "EXT_blend_minmax", "EXT_color_buffer_half_float", "EXT_disjoint_timer_query", "EXT_float_blend", "EXT_frag_depth", "EXT_shader_texture_lod", "EXT_texture_compression_rgtc", "EXT_texture_filter_anisotropic", "EXT_sRGB", "KHR_parallel_shader_compile", "OES_element_index_uint", "OES_fbo_render_mipmap", "OES_standard_derivatives", "OES_texture_float", "OES_texture_float_linear", "OES_texture_half_float", "OES_texture_half_float_linear", "OES_vertex_array_object", "WEBGL_color_buffer_float", "WEBGL_compressed_texture_s3tc", "WEBGL_compressed_texture_s3tc_srgb", "WEBGL_debug_renderer_info", "WEBGL_debug_shaders", "WEBGL_depth_texture", "WEBGL_draw_buffers", "WEBGL_lose_context", "WEBGL_multi_draw"]
                },
                clearColor: function (...args) {
                    return undefined
                },
                enable: function () {
                    return undefined
                },
                depthFunc: function () {
                    return undefined
                },
                clear: function () {
                    return undefined
                },
                getContextAttributes: function () {
                    return {
                        "alpha": true,
                        "antialias": true,
                        "depth": true,
                        "desynchronized": false,
                        "failIfMajorPerformanceCaveat": false,
                        "powerPreference": "default",
                        "premultipliedAlpha": true,
                        "preserveDrawingBuffer": false,
                        "stencil": false,
                        "xrCompatible": false
                    };
                },
                getExtension: function (...args) {
                    switch (args[0]) {
                        case 'WEBGL_draw_buffers':
                            return {
                                COLOR_ATTACHMENT0_WEBGL: 36064,
                                COLOR_ATTACHMENT1_WEBGL: 36065,
                                COLOR_ATTACHMENT2_WEBGL: 36066,
                                COLOR_ATTACHMENT3_WEBGL: 36067,
                                COLOR_ATTACHMENT4_WEBGL: 36068,
                                COLOR_ATTACHMENT5_WEBGL: 36069,
                                COLOR_ATTACHMENT6_WEBGL: 36070,
                                COLOR_ATTACHMENT7_WEBGL: 36071,
                                COLOR_ATTACHMENT8_WEBGL: 36072,
                                COLOR_ATTACHMENT9_WEBGL: 36073,
                                COLOR_ATTACHMENT10_WEBGL: 36074,
                                COLOR_ATTACHMENT11_WEBGL: 36075,
                                COLOR_ATTACHMENT12_WEBGL: 36076,
                                COLOR_ATTACHMENT13_WEBGL: 36077,
                                COLOR_ATTACHMENT14_WEBGL: 36078,
                                COLOR_ATTACHMENT15_WEBGL: 36079,
                                DRAW_BUFFER0_WEBGL: 34853,
                                DRAW_BUFFER1_WEBGL: 34854,
                                DRAW_BUFFER2_WEBGL: 34855,
                                DRAW_BUFFER3_WEBGL: 34856,
                                DRAW_BUFFER4_WEBGL: 34857,
                                DRAW_BUFFER5_WEBGL: 34858,
                                DRAW_BUFFER6_WEBGL: 34859,
                                DRAW_BUFFER7_WEBGL: 34860,
                                DRAW_BUFFER8_WEBGL: 34861,
                                DRAW_BUFFER9_WEBGL: 34862,
                                DRAW_BUFFER10_WEBGL: 34863,
                                DRAW_BUFFER11_WEBGL: 34864,
                                DRAW_BUFFER12_WEBGL: 34865,
                                DRAW_BUFFER13_WEBGL: 34866,
                                DRAW_BUFFER14_WEBGL: 34867,
                                DRAW_BUFFER15_WEBGL: 34868,
                                MAX_COLOR_ATTACHMENTS_WEBGL: 36063,
                                MAX_DRAW_BUFFERS_WEBGL: 34852
                            }
                        case 'WEBGL_debug_renderer_info':
                            return {
                                UNMASKED_RENDERER_WEBGL: 37446,
                                UNMASKED_VENDOR_WEBGL: 37445
                            }

                        case 'EXT_texture_filter_anisotropic':
                            return {
                                MAX_TEXTURE_MAX_ANISOTROPY_EXT: 34047,
                                TEXTURE_MAX_ANISOTROPY_EXT: 34046
                            }
                    }

                    // debugger;
                    return {
                        MAX_TEXTURE_MAX_ANISOTROPY_EXT: 34047,
                        UNMASKED_VENDOR_WEBGL: 37445,
                        UNMASKED_RENDERER_WEBGL: 37446,
                    }
                }
            };

            class WebGLRenderingContext {
                constructor(...args) {
                }

                getParameter(...args) {
                    if (args[0] === 37445 || args[0] === 37446) {
                        throw TypeError('Illegal invocation');
                    }
                };
            }

            window.WebGLRenderingContext = WebGLRenderingContext;
            const webGL2RenderingContextData = {
                ACTIVE_ATTRIBUTES: 35721,
                ACTIVE_TEXTURE: 34016,
                ACTIVE_UNIFORMS: 35718,
                ACTIVE_UNIFORM_BLOCKS: 35382,
                ALIASED_LINE_WIDTH_RANGE: 33902,
                ALIASED_POINT_SIZE_RANGE: 33901,
                ALPHA: 6406,
                ALPHA_BITS: 3413,
                ALREADY_SIGNALED: 37146,
                ALWAYS: 519,
                ANY_SAMPLES_PASSED: 35887,
                ANY_SAMPLES_PASSED_CONSERVATIVE: 36202,
                ARRAY_BUFFER: 34962,
                ARRAY_BUFFER_BINDING: 34964,
                ATTACHED_SHADERS: 35717,
                BACK: 1029,
                BLEND: 3042,
                BLEND_COLOR: 32773,
                BLEND_DST_ALPHA: 32970,
                BLEND_DST_RGB: 32968,
                BLEND_EQUATION: 32777,
                BLEND_EQUATION_ALPHA: 34877,
                BLEND_EQUATION_RGB: 32777,
                BLEND_SRC_ALPHA: 32971,
                BLEND_SRC_RGB: 32969,
                BLUE_BITS: 3412,
                BOOL: 35670,
                BOOL_VEC2: 35671,
                BOOL_VEC3: 35672,
                BOOL_VEC4: 35673,
                BROWSER_DEFAULT_WEBGL: 37444,
                BUFFER_SIZE: 34660,
                BUFFER_USAGE: 34661,
                BYTE: 5120,
                CCW: 2305,
                CLAMP_TO_EDGE: 33071,
                COLOR: 6144,
                COLOR_ATTACHMENT0: 36064,
                COLOR_ATTACHMENT1: 36065,
                COLOR_ATTACHMENT2: 36066,
                COLOR_ATTACHMENT3: 36067,
                COLOR_ATTACHMENT4: 36068,
                COLOR_ATTACHMENT5: 36069,
                COLOR_ATTACHMENT6: 36070,
                COLOR_ATTACHMENT7: 36071,
                COLOR_ATTACHMENT8: 36072,
                COLOR_ATTACHMENT9: 36073,
                COLOR_ATTACHMENT10: 36074,
                COLOR_ATTACHMENT11: 36075,
                COLOR_ATTACHMENT12: 36076,
                COLOR_ATTACHMENT13: 36077,
                COLOR_ATTACHMENT14: 36078,
                COLOR_ATTACHMENT15: 36079,
                COLOR_BUFFER_BIT: 16384,
                COLOR_CLEAR_VALUE: 3106,
                COLOR_WRITEMASK: 3107,
                COMPARE_REF_TO_TEXTURE: 34894,
                COMPILE_STATUS: 35713,
                COMPRESSED_TEXTURE_FORMATS: 34467,
                CONDITION_SATISFIED: 37148,
                CONSTANT_ALPHA: 32771,
                CONSTANT_COLOR: 32769,
                CONTEXT_LOST_WEBGL: 37442,
                COPY_READ_BUFFER: 36662,
                COPY_READ_BUFFER_BINDING: 36662,
                COPY_WRITE_BUFFER: 36663,
                COPY_WRITE_BUFFER_BINDING: 36663,
                CULL_FACE: 2884,
                CULL_FACE_MODE: 2885,
                CURRENT_PROGRAM: 35725,
                CURRENT_QUERY: 34917,
                CURRENT_VERTEX_ATTRIB: 34342,
                CW: 2304,
                DECR: 7683,
                DECR_WRAP: 34056,
                DELETE_STATUS: 35712,
                DEPTH: 6145,
                DEPTH24_STENCIL8: 35056,
                DEPTH32F_STENCIL8: 36013,
                DEPTH_ATTACHMENT: 36096,
                DEPTH_BITS: 3414,
                DEPTH_BUFFER_BIT: 256,
                DEPTH_CLEAR_VALUE: 2931,
                DEPTH_COMPONENT: 6402,
                DEPTH_COMPONENT16: 33189,
                DEPTH_COMPONENT24: 33190,
                DEPTH_COMPONENT32F: 36012,
                DEPTH_FUNC: 2932,
                DEPTH_RANGE: 2928,
                DEPTH_STENCIL: 34041,
                DEPTH_STENCIL_ATTACHMENT: 33306,
                DEPTH_TEST: 2929,
                DEPTH_WRITEMASK: 2930,
                DITHER: 3024,
                DONT_CARE: 4352,
                DRAW_BUFFER0: 34853,
                DRAW_BUFFER1: 34854,
                DRAW_BUFFER2: 34855,
                DRAW_BUFFER3: 34856,
                DRAW_BUFFER4: 34857,
                DRAW_BUFFER5: 34858,
                DRAW_BUFFER6: 34859,
                DRAW_BUFFER7: 34860,
                DRAW_BUFFER8: 34861,
                DRAW_BUFFER9: 34862,
                DRAW_BUFFER10: 34863,
                DRAW_BUFFER11: 34864,
                DRAW_BUFFER12: 34865,
                DRAW_BUFFER13: 34866,
                DRAW_BUFFER14: 34867,
                DRAW_BUFFER15: 34868,
                DRAW_FRAMEBUFFER: 36009,
                DRAW_FRAMEBUFFER_BINDING: 36006,
                DST_ALPHA: 772,
                DST_COLOR: 774,
                DYNAMIC_COPY: 35050,
                DYNAMIC_DRAW: 35048,
                DYNAMIC_READ: 35049,
                ELEMENT_ARRAY_BUFFER: 34963,
                ELEMENT_ARRAY_BUFFER_BINDING: 34965,
                EQUAL: 514,
                FASTEST: 4353,
                FLOAT: 5126,
                FLOAT_32_UNSIGNED_INT_24_8_REV: 36269,
                FLOAT_MAT2: 35674,
                FLOAT_MAT2x3: 35685,
                FLOAT_MAT2x4: 35686,
                FLOAT_MAT3: 35675,
                FLOAT_MAT3x2: 35687,
                FLOAT_MAT3x4: 35688,
                FLOAT_MAT4: 35676,
                FLOAT_MAT4x2: 35689,
                FLOAT_MAT4x3: 35690,
                FLOAT_VEC2: 35664,
                FLOAT_VEC3: 35665,
                FLOAT_VEC4: 35666,
                FRAGMENT_SHADER: 35632,
                FRAGMENT_SHADER_DERIVATIVE_HINT: 35723,
                FRAMEBUFFER: 36160,
                FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: 33301,
                FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: 33300,
                FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: 33296,
                FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: 33297,
                FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: 33302,
                FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: 33299,
                FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 36049,
                FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 36048,
                FRAMEBUFFER_ATTACHMENT_RED_SIZE: 33298,
                FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: 33303,
                FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 36051,
                FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: 36052,
                FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 36050,
                FRAMEBUFFER_BINDING: 36006,
                FRAMEBUFFER_COMPLETE: 36053,
                FRAMEBUFFER_DEFAULT: 33304,
                FRAMEBUFFER_INCOMPLETE_ATTACHMENT: 36054,
                FRAMEBUFFER_INCOMPLETE_DIMENSIONS: 36057,
                FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: 36055,
                FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: 36182,
                FRAMEBUFFER_UNSUPPORTED: 36061,
                FRONT: 1028,
                FRONT_AND_BACK: 1032,
                FRONT_FACE: 2886,
                FUNC_ADD: 32774,
                FUNC_REVERSE_SUBTRACT: 32779,
                FUNC_SUBTRACT: 32778,
                GENERATE_MIPMAP_HINT: 33170,
                GEQUAL: 518,
                GREATER: 516,
                GREEN_BITS: 3411,
                HALF_FLOAT: 5131,
                HIGH_FLOAT: 36338,
                HIGH_INT: 36341,
                IMPLEMENTATION_COLOR_READ_FORMAT: 35739,
                IMPLEMENTATION_COLOR_READ_TYPE: 35738,
                INCR: 7682,
                INCR_WRAP: 34055,
                INT: 5124,
                INTERLEAVED_ATTRIBS: 35980,
                INT_2_10_10_10_REV: 36255,
                INT_SAMPLER_2D: 36298,
                INT_SAMPLER_2D_ARRAY: 36303,
                INT_SAMPLER_3D: 36299,
                INT_SAMPLER_CUBE: 36300,
                INT_VEC2: 35667,
                INT_VEC3: 35668,
                INT_VEC4: 35669,
                INVALID_ENUM: 1280,
                INVALID_FRAMEBUFFER_OPERATION: 1286,
                INVALID_INDEX: 4294967295,
                INVALID_OPERATION: 1282,
                INVALID_VALUE: 1281,
                INVERT: 5386,
                KEEP: 7680,
                LEQUAL: 515,
                LESS: 513,
                LINEAR: 9729,
                LINEAR_MIPMAP_LINEAR: 9987,
                LINEAR_MIPMAP_NEAREST: 9985,
                LINES: 1,
                LINE_LOOP: 2,
                LINE_STRIP: 3,
                LINE_WIDTH: 2849,
                LINK_STATUS: 35714,
                LOW_FLOAT: 36336,
                LOW_INT: 36339,
                LUMINANCE: 6409,
                LUMINANCE_ALPHA: 6410,
                MAX: 32776,
                MAX_3D_TEXTURE_SIZE: 32883,
                MAX_ARRAY_TEXTURE_LAYERS: 35071,
                MAX_CLIENT_WAIT_TIMEOUT_WEBGL: 37447,
                MAX_COLOR_ATTACHMENTS: 36063,
                MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: 35379,
                MAX_COMBINED_TEXTURE_IMAGE_UNITS: 35661,
                MAX_COMBINED_UNIFORM_BLOCKS: 35374,
                MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS: 35377,
                MAX_CUBE_MAP_TEXTURE_SIZE: 34076,
                MAX_DRAW_BUFFERS: 34852,
                MAX_ELEMENTS_INDICES: 33001,
                MAX_ELEMENTS_VERTICES: 33000,
                MAX_ELEMENT_INDEX: 36203,
                MAX_FRAGMENT_INPUT_COMPONENTS: 37157,
                MAX_FRAGMENT_UNIFORM_BLOCKS: 35373,
                MAX_FRAGMENT_UNIFORM_COMPONENTS: 35657,
                MAX_FRAGMENT_UNIFORM_VECTORS: 36349,
                MAX_PROGRAM_TEXEL_OFFSET: 35077,
                MAX_RENDERBUFFER_SIZE: 34024,
                MAX_SAMPLES: 36183,
                MAX_SERVER_WAIT_TIMEOUT: 37137,
                MAX_TEXTURE_IMAGE_UNITS: 34930,
                MAX_TEXTURE_LOD_BIAS: 34045,
                MAX_TEXTURE_SIZE: 3379,
                MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS: 35978,
                MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS: 35979,
                MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS: 35968,
                MAX_UNIFORM_BLOCK_SIZE: 35376,
                MAX_UNIFORM_BUFFER_BINDINGS: 35375,
                MAX_VARYING_COMPONENTS: 35659,
                MAX_VARYING_VECTORS: 36348,
                MAX_VERTEX_ATTRIBS: 34921,
                MAX_VERTEX_OUTPUT_COMPONENTS: 37154,
                MAX_VERTEX_TEXTURE_IMAGE_UNITS: 35660,
                MAX_VERTEX_UNIFORM_BLOCKS: 35371,
                MAX_VERTEX_UNIFORM_COMPONENTS: 35658,
                MAX_VERTEX_UNIFORM_VECTORS: 36347,
                MAX_VIEWPORT_DIMS: 3386,
                MEDIUM_FLOAT: 36337,
                MEDIUM_INT: 36340,
                MIN: 32775,
                MIN_PROGRAM_TEXEL_OFFSET: 35076,
                MIRRORED_REPEAT: 33648,
                NEAREST: 9728,
                NEAREST_MIPMAP_LINEAR: 9986,
                NEAREST_MIPMAP_NEAREST: 9984,
                NEVER: 512,
                NICEST: 4354,
                NONE: 0,
                NOTEQUAL: 517,
                NO_ERROR: 0,
                OBJECT_TYPE: 37138,
                ONE: 1,
                ONE_MINUS_CONSTANT_ALPHA: 32772,
                ONE_MINUS_CONSTANT_COLOR: 32770,
                ONE_MINUS_DST_ALPHA: 773,
                ONE_MINUS_DST_COLOR: 775,
                ONE_MINUS_SRC_ALPHA: 771,
                ONE_MINUS_SRC_COLOR: 769,
                OUT_OF_MEMORY: 1285,
                PACK_ALIGNMENT: 3333,
                PACK_ROW_LENGTH: 3330,
                PACK_SKIP_PIXELS: 3332,
                PACK_SKIP_ROWS: 3331,
                PIXEL_PACK_BUFFER: 35051,
                PIXEL_PACK_BUFFER_BINDING: 35053,
                PIXEL_UNPACK_BUFFER: 35052,
                PIXEL_UNPACK_BUFFER_BINDING: 35055,
                POINTS: 0,
                POLYGON_OFFSET_FACTOR: 32824,
                POLYGON_OFFSET_FILL: 32823,
                POLYGON_OFFSET_UNITS: 10752,
                QUERY_RESULT: 34918,
                QUERY_RESULT_AVAILABLE: 34919,
                R8: 33321,
                R8I: 33329,
                R8UI: 33330,
                R8_SNORM: 36756,
                R11F_G11F_B10F: 35898,
                R16F: 33325,
                R16I: 33331,
                R16UI: 33332,
                R32F: 33326,
                R32I: 33333,
                R32UI: 33334,
                RASTERIZER_DISCARD: 35977,
                READ_BUFFER: 3074,
                READ_FRAMEBUFFER: 36008,
                READ_FRAMEBUFFER_BINDING: 36010,
                RED: 6403,
                RED_BITS: 3410,
                RED_INTEGER: 36244,
                RENDERBUFFER: 36161,
                RENDERBUFFER_ALPHA_SIZE: 36179,
                RENDERBUFFER_BINDING: 36007,
                RENDERBUFFER_BLUE_SIZE: 36178,
                RENDERBUFFER_DEPTH_SIZE: 36180,
                RENDERBUFFER_GREEN_SIZE: 36177,
                RENDERBUFFER_HEIGHT: 36163,
                RENDERBUFFER_INTERNAL_FORMAT: 36164,
                RENDERBUFFER_RED_SIZE: 36176,
                RENDERBUFFER_SAMPLES: 36011,
                RENDERBUFFER_STENCIL_SIZE: 36181,
                RENDERBUFFER_WIDTH: 36162,
                RENDERER: 7937,
                REPEAT: 10497,
                REPLACE: 7681,
                RG: 33319,
                RG8: 33323,
                RG8I: 33335,
                RG8UI: 33336,
                RG8_SNORM: 36757,
                RG16F: 33327,
                RG16I: 33337,
                RG16UI: 33338,
                RG32F: 33328,
                RG32I: 33339,
                RG32UI: 33340,
                RGB: 6407,
                RGB5_A1: 32855,
                RGB8: 32849,
                RGB8I: 36239,
                RGB8UI: 36221,
                RGB8_SNORM: 36758,
                RGB9_E5: 35901,
                RGB10_A2: 32857,
                RGB10_A2UI: 36975,
                RGB16F: 34843,
                RGB16I: 36233,
                RGB16UI: 36215,
                RGB32F: 34837,
                RGB32I: 36227,
                RGB32UI: 36209,
                RGB565: 36194,
                RGBA: 6408,
                RGBA4: 32854,
                RGBA8: 32856,
                RGBA8I: 36238,
                RGBA8UI: 36220,
                RGBA8_SNORM: 36759,
                RGBA16F: 34842,
                RGBA16I: 36232,
                RGBA16UI: 36214,
                RGBA32F: 34836,
                RGBA32I: 36226,
                RGBA32UI: 36208,
                RGBA_INTEGER: 36249,
                RGB_INTEGER: 36248,
                RG_INTEGER: 33320,
                SAMPLER_2D: 35678,
                SAMPLER_2D_ARRAY: 36289,
                SAMPLER_2D_ARRAY_SHADOW: 36292,
                SAMPLER_2D_SHADOW: 35682,
                SAMPLER_3D: 35679,
                SAMPLER_BINDING: 35097,
                SAMPLER_CUBE: 35680,
                SAMPLER_CUBE_SHADOW: 36293,
                SAMPLES: 32937,
                SAMPLE_ALPHA_TO_COVERAGE: 32926,
                SAMPLE_BUFFERS: 32936,
                SAMPLE_COVERAGE: 32928,
                SAMPLE_COVERAGE_INVERT: 32939,
                SAMPLE_COVERAGE_VALUE: 32938,
                SCISSOR_BOX: 3088,
                SCISSOR_TEST: 3089,
                SEPARATE_ATTRIBS: 35981,
                SHADER_TYPE: 35663,
                SHADING_LANGUAGE_VERSION: 35724,
                SHORT: 5122,
                SIGNALED: 37145,
                SIGNED_NORMALIZED: 36764,
                SRC_ALPHA: 770,
                SRC_ALPHA_SATURATE: 776,
                SRC_COLOR: 768,
                SRGB: 35904,
                SRGB8: 35905,
                SRGB8_ALPHA8: 35907,
                STATIC_COPY: 35046,
                STATIC_DRAW: 35044,
                STATIC_READ: 35045,
                STENCIL: 6146,
                STENCIL_ATTACHMENT: 36128,
                STENCIL_BACK_FAIL: 34817,
                STENCIL_BACK_FUNC: 34816,
                STENCIL_BACK_PASS_DEPTH_FAIL: 34818,
                STENCIL_BACK_PASS_DEPTH_PASS: 34819,
                STENCIL_BACK_REF: 36003,
                STENCIL_BACK_VALUE_MASK: 36004,
                STENCIL_BACK_WRITEMASK: 36005,
                STENCIL_BITS: 3415,
                STENCIL_BUFFER_BIT: 1024,
                STENCIL_CLEAR_VALUE: 2961,
                STENCIL_FAIL: 2964,
                STENCIL_FUNC: 2962,
                STENCIL_INDEX8: 36168,
                STENCIL_PASS_DEPTH_FAIL: 2965,
                STENCIL_PASS_DEPTH_PASS: 2966,
                STENCIL_REF: 2967,
                STENCIL_TEST: 2960,
                STENCIL_VALUE_MASK: 2963,
                STENCIL_WRITEMASK: 2968,
                STREAM_COPY: 35042,
                STREAM_DRAW: 35040,
                STREAM_READ: 35041,
                SUBPIXEL_BITS: 3408,
                SYNC_CONDITION: 37139,
                SYNC_FENCE: 37142,
                SYNC_FLAGS: 37141,
                SYNC_FLUSH_COMMANDS_BIT: 1,
                SYNC_GPU_COMMANDS_COMPLETE: 37143,
                SYNC_STATUS: 37140,
                TEXTURE: 5890,
                TEXTURE0: 33984,
                TEXTURE1: 33985,
                TEXTURE2: 33986,
                TEXTURE3: 33987,
                TEXTURE4: 33988,
                TEXTURE5: 33989,
                TEXTURE6: 33990,
                TEXTURE7: 33991,
                TEXTURE8: 33992,
                TEXTURE9: 33993,
                TEXTURE10: 33994,
                TEXTURE11: 33995,
                TEXTURE12: 33996,
                TEXTURE13: 33997,
                TEXTURE14: 33998,
                TEXTURE15: 33999,
                TEXTURE16: 34000,
                TEXTURE17: 34001,
                TEXTURE18: 34002,
                TEXTURE19: 34003,
                TEXTURE20: 34004,
                TEXTURE21: 34005,
                TEXTURE22: 34006,
                TEXTURE23: 34007,
                TEXTURE24: 34008,
                TEXTURE25: 34009,
                TEXTURE26: 34010,
                TEXTURE27: 34011,
                TEXTURE28: 34012,
                TEXTURE29: 34013,
                TEXTURE30: 34014,
                TEXTURE31: 34015,
                TEXTURE_2D: 3553,
                TEXTURE_2D_ARRAY: 35866,
                TEXTURE_3D: 32879,
                TEXTURE_BASE_LEVEL: 33084,
                TEXTURE_BINDING_2D: 32873,
                TEXTURE_BINDING_2D_ARRAY: 35869,
                TEXTURE_BINDING_3D: 32874,
                TEXTURE_BINDING_CUBE_MAP: 34068,
                TEXTURE_COMPARE_FUNC: 34893,
                TEXTURE_COMPARE_MODE: 34892,
                TEXTURE_CUBE_MAP: 34067,
                TEXTURE_CUBE_MAP_NEGATIVE_X: 34070,
                TEXTURE_CUBE_MAP_NEGATIVE_Y: 34072,
                TEXTURE_CUBE_MAP_NEGATIVE_Z: 34074,
                TEXTURE_CUBE_MAP_POSITIVE_X: 34069,
                TEXTURE_CUBE_MAP_POSITIVE_Y: 34071,
                TEXTURE_CUBE_MAP_POSITIVE_Z: 34073,
                TEXTURE_IMMUTABLE_FORMAT: 37167,
                TEXTURE_IMMUTABLE_LEVELS: 33503,
                TEXTURE_MAG_FILTER: 10240,
                TEXTURE_MAX_LEVEL: 33085,
                TEXTURE_MAX_LOD: 33083,
                TEXTURE_MIN_FILTER: 10241,
                TEXTURE_MIN_LOD: 33082,
                TEXTURE_WRAP_R: 32882,
                TEXTURE_WRAP_S: 10242,
                TEXTURE_WRAP_T: 10243,
                TIMEOUT_EXPIRED: 37147,
                TIMEOUT_IGNORED: -1,
                TRANSFORM_FEEDBACK: 36386,
                TRANSFORM_FEEDBACK_ACTIVE: 36388,
                TRANSFORM_FEEDBACK_BINDING: 36389,
                TRANSFORM_FEEDBACK_BUFFER: 35982,
                TRANSFORM_FEEDBACK_BUFFER_BINDING: 35983,
                TRANSFORM_FEEDBACK_BUFFER_MODE: 35967,
                TRANSFORM_FEEDBACK_BUFFER_SIZE: 35973,
                TRANSFORM_FEEDBACK_BUFFER_START: 35972,
                TRANSFORM_FEEDBACK_PAUSED: 36387,
                TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: 35976,
                TRANSFORM_FEEDBACK_VARYINGS: 35971,
                TRIANGLES: 4,
                TRIANGLE_FAN: 6,
                TRIANGLE_STRIP: 5,
                UNIFORM_ARRAY_STRIDE: 35388,
                UNIFORM_BLOCK_ACTIVE_UNIFORMS: 35394,
                UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: 35395,
                UNIFORM_BLOCK_BINDING: 35391,
                UNIFORM_BLOCK_DATA_SIZE: 35392,
                UNIFORM_BLOCK_INDEX: 35386,
                UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: 35398,
                UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: 35396,
                UNIFORM_BUFFER: 35345,
                UNIFORM_BUFFER_BINDING: 35368,
                UNIFORM_BUFFER_OFFSET_ALIGNMENT: 35380,
                UNIFORM_BUFFER_SIZE: 35370,
                UNIFORM_BUFFER_START: 35369,
                UNIFORM_IS_ROW_MAJOR: 35390,
                UNIFORM_MATRIX_STRIDE: 35389,
                UNIFORM_OFFSET: 35387,
                UNIFORM_SIZE: 35384,
                UNIFORM_TYPE: 35383,
                UNPACK_ALIGNMENT: 3317,
                UNPACK_COLORSPACE_CONVERSION_WEBGL: 37443,
                UNPACK_FLIP_Y_WEBGL: 37440,
                UNPACK_IMAGE_HEIGHT: 32878,
                UNPACK_PREMULTIPLY_ALPHA_WEBGL: 37441,
                UNPACK_ROW_LENGTH: 3314,
                UNPACK_SKIP_IMAGES: 32877,
                UNPACK_SKIP_PIXELS: 3316,
                UNPACK_SKIP_ROWS: 3315,
                UNSIGNALED: 37144,
                UNSIGNED_BYTE: 5121,
                UNSIGNED_INT: 5125,
                UNSIGNED_INT_2_10_10_10_REV: 33640,
                UNSIGNED_INT_5_9_9_9_REV: 35902,
                UNSIGNED_INT_10F_11F_11F_REV: 35899,
                UNSIGNED_INT_24_8: 34042,
                UNSIGNED_INT_SAMPLER_2D: 36306,
                UNSIGNED_INT_SAMPLER_2D_ARRAY: 36311,
                UNSIGNED_INT_SAMPLER_3D: 36307,
                UNSIGNED_INT_SAMPLER_CUBE: 36308,
                UNSIGNED_INT_VEC2: 36294,
                UNSIGNED_INT_VEC3: 36295,
                UNSIGNED_INT_VEC4: 36296,
                UNSIGNED_NORMALIZED: 35863,
                UNSIGNED_SHORT: 5123,
                UNSIGNED_SHORT_4_4_4_4: 32819,
                UNSIGNED_SHORT_5_5_5_1: 32820,
                UNSIGNED_SHORT_5_6_5: 33635,
                VALIDATE_STATUS: 35715,
                VENDOR: 7936,
                VERSION: 7938,
                VERTEX_ARRAY_BINDING: 34229,
                VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 34975,
                VERTEX_ATTRIB_ARRAY_DIVISOR: 35070,
                VERTEX_ATTRIB_ARRAY_ENABLED: 34338,
                VERTEX_ATTRIB_ARRAY_INTEGER: 35069,
                VERTEX_ATTRIB_ARRAY_NORMALIZED: 34922,
                VERTEX_ATTRIB_ARRAY_POINTER: 34373,
                VERTEX_ATTRIB_ARRAY_SIZE: 34339,
                VERTEX_ATTRIB_ARRAY_STRIDE: 34340,
                VERTEX_ATTRIB_ARRAY_TYPE: 34341,
                VERTEX_SHADER: 35633,
                VIEWPORT: 2978,
                WAIT_FAILED: 37149,
                ZERO: 0,
                getSupportedExtensions: function () {
                    return ["EXT_color_buffer_float", "EXT_color_buffer_half_float", "EXT_disjoint_timer_query_webgl2", "EXT_float_blend", "EXT_texture_compression_rgtc", "EXT_texture_filter_anisotropic", "EXT_texture_norm16", "KHR_parallel_shader_compile", "OES_draw_buffers_indexed", "OES_texture_float_linear", "WEBGL_compressed_texture_s3tc", "WEBGL_compressed_texture_s3tc_srgb", "WEBGL_debug_renderer_info", "WEBGL_debug_shaders", "WEBGL_lose_context", "WEBGL_multi_draw", "WEBGL_provoking_vertex"];
                },
                isEnabled: function (value) {
                    switch (value) {
                        case 2960:
                            return false
                    }
                    return false
                },
                getShaderPrecisionFormat: function (value1, value2) {
                    let result = {precision: 23, rangeMax: 127, rangeMin: 127};
                    if (value1 === 35632) {
                        if (value2 === 36341 || value2 === 36340 || value2 === 36339) {
                            result = {rangeMin: 31, rangeMax: 30, precision: 0};
                        } else {
                            result = {rangeMin: 127, rangeMax: 127, precision: 23};
                        }
                    } else if (value1 === 35633) {
                        if (value2 === 36341 || value2 === 36340 || value2 === 36339) {
                            result = {rangeMin: 31, rangeMax: 30, precision: 0};
                        } else {
                            result = {rangeMin: 31, rangeMax: 30, precision: 0};
                        }
                    }
                    // debugger
                    return result
                },
                getParameter: function (...args) {
                    switch (args[0]) {
                        case 34047:
                            return 16;
                        case 3413:
                            return 8;
                        case 37445:
                            return 'Google Inc. (ATI Technologies Inc.)';
                        // return 'Google Inc. (Apple)';
                        case 37446:
                            return 'ANGLE (ATI Technologies Inc., AMD Radeon Pro 555X OpenGL Engine, OpenGL 4.1 ATI-4.6.20)';
                        // return 'ANGLE (Apple, Apple M2 Max, OpenGL 4.1)';
                        case 7936:
                            return 'WebKit'
                        case 7937:
                            return 'WebKit WebGL'
                        case 34852:
                            return 8;
                        case 36347:
                            return 1024;
                        case 3386:
                            return new Int32Array([16384, 16384]);
                        case 34921:
                            return 16;
                        case 35724:
                            return 'WebGL GLSL ES 2.0 (OpenGL ES GLSL ES 2.0 Chromium)';
                        case 7938:
                            return 'WebGL 2.0 (OpenGL ES 3.0 Chromium)';
                        case 36348:
                            return 31;
                        case 33901:
                            return new Float32Array([1, 64]);
                        case 32937:
                            return 4;
                        case 35661:
                            return 32;
                        case 34930:
                            return 16;
                        case 36349:
                            return 1024;
                        case 33902:
                            return new Float32Array([1, 1]);
                        case 34024:
                            return 16384;
                        case 35660:
                            return 16;
                        case 2968:
                            return 2147483647;
                        case 3379:
                            return 16384;
                        case 34076:
                            return 16384;
                        case 3412:
                            return 8;
                        case 3414:
                            return 24;
                        case 3411:
                            return 8;
                        case 3410:
                            return 8;
                        case 3415:
                            return 0;
                    }
                    // debugger;
                    return 8
                },
                getExtension: function (...args) {
                    switch (args[0]) {
                        case 'WEBGL_draw_buffers':
                            return null
                        case 'WEBGL_debug_renderer_info':
                            return {
                                UNMASKED_RENDERER_WEBGL: 37446,
                                UNMASKED_VENDOR_WEBGL: 37445
                            }

                        case 'EXT_texture_filter_anisotropic':
                            return {
                                MAX_TEXTURE_MAX_ANISOTROPY_EXT: 34047,
                                TEXTURE_MAX_ANISOTROPY_EXT: 34046
                            }
                    }
                    debugger;
                    return {}
                }
            }

            class WebGL2RenderingContext {
                constructor(...args) {
                    this.drawingBufferColorSpace = "srgb";
                    this.drawingBufferHeight = 150;
                    this.drawingBufferWidth = 300;
                    this.unpackColorSpace = "srgb";
                }
            }

            WebGL2RenderingContext.prototype.toString = function () {
                return "[object WebGL2RenderingContext]";
            }
            window.WebGL2RenderingContext = WebGL2RenderingContext;

            let oriHTMLCanvasElementGetContext = window.HTMLCanvasElement.prototype.getContext;
            window.HTMLCanvasElement.prototype.getContext = function (...args) {
                if (args[0] === 'webgl') {
                    const webGLRenderingContext = new WebGLRenderingContext();
                    this.webgl = true;
                    webGLRenderingContext.canvas = this;
                    webGLRenderingContextData.canvas = this;
                    Object.setPrototypeOf(webGLRenderingContext, webGLRenderingContextData);
                    return webGLRenderingContext;
                } else if (args[0] === 'webgl2') {
                    this.webgl = true;
                    const webGL2RenderingContext = new WebGL2RenderingContext();
                    webGL2RenderingContext.canvas = this;
                    webGL2RenderingContextData.canvas = this;
                    Object.setPrototypeOf(webGL2RenderingContext, webGL2RenderingContextData);
                    return webGL2RenderingContext
                }
                return oriHTMLCanvasElementGetContext.call(this, ...args);
            };

            function getWindowChrome(needApp = true) {
                const chrome = {
                    loadTimes: function () {
                        return {
                            "requestTime": 1710813739.42,
                            "startLoadTime": 1710813739.42,
                            "commitLoadTime": 1710813743.668,
                            "finishDocumentLoadTime": 1710813743.791,
                            "finishLoadTime": 1710813745.325,
                            "firstPaintTime": 0,
                            "firstPaintAfterLoadTime": 0,
                            "navigationType": "Resubmitted",
                            "wasFetchedViaSpdy": true,
                            "wasNpnNegotiated": true,
                            "npnNegotiatedProtocol": "h2",
                            "wasAlternateProtocolAvailable": false,
                            "connectionInfo": "h2"
                        }
                    },
                    csi: function () {
                    }
                }
                if (needApp) {
                    chrome.app = {
                        "isInstalled": false,
                        "getDetails": function () {
                        },
                        "getIsInstalled": function () {
                        },
                        "installState": function () {
                        },
                        "runningState": function () {
                        },
                        "InstallState": {
                            "DISABLED": "disabled",
                            "INSTALLED": "installed",
                            "NOT_INSTALLED": "not_installed"
                        },
                        "RunningState": {
                            "CANNOT_RUN": "cannot_run",
                            "READY_TO_RUN": "ready_to_run",
                            "RUNNING": "running"
                        }
                    }
                }

                Object.setPrototypeOf(chrome.loadTimes, {
                    toString: function () {
                        return "function () { [native code] }";
                    }
                })
                Object.defineProperty(chrome.csi, 'name', {
                    get() {
                        return '';
                    }
                });
                Object.defineProperty(chrome.loadTimes, 'name', {
                    get() {
                        return '';
                    }
                });
                return chrome;
            }

            window.chrome = getWindowChrome();
            window.SpeechSynthesis = new MySpeechSynthesis();

            class webkitRTCPeerConnection {

                createDataChannel(...args) {
                    return {};
                }

                setLocalDescription(...args) {

                }

                onicecandidate(...args) {

                }

                createOffer(success, error) {
                    setTimeout(function () {
                        success({
                            type: "offer",
                            sdp: 'v=0\r\no=- 2131392729114402304 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:SeF3\r\na=ice-pwd:adY3Wxo2hamGK/n3ho2tAM9+\r\na=ice-options:trickle\r\na=fingerprint:sha-256 74:72:98:5E:BF:64:52:A3:2A:E0:61:3C:C4:83:D3:FC:3D:76:FB:A6:FD:2E:FF:F9:0F:7F:02:07:CA:9B:33:25\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n'
                        });
                    }, 0);
                }
            }

            Object.defineProperty(webkitRTCPeerConnection.prototype, 'onicecandidate', {
                configurable: true,
                enumerable: true,
                set: function (func) {
                    setTimeout(function () {
                        const address = randomUUID() + ".local";
                        const candidate = `candidate:2224236457 1 udp 2113937151 ${address} 63715 typ host generation 0 ufrag ZAez network-cost 999`;
                        const timeStamp = 37928.80000000447 + randomNum(0, 1000);
                        func({
                            "isTrusted": true,
                            "bubbles": false,
                            "cancelBubble": false,
                            "cancelable": false,
                            "composed": false,
                            "defaultPrevented": false,
                            "eventPhase": 2,
                            "returnValue": true,
                            "timeStamp": timeStamp,
                            "type": "icecandidate",
                            "candidate": {
                                "address": address,
                                "candidate": candidate,
                                "component": "rtp",
                                "foundation": "2224236457",
                                "port": 63715,
                                "priority": 2113937151,
                                "protocol": "udp",
                                "relatedAddress": null,
                                "relatedPort": null,
                                "sdpMLineIndex": 0,
                                "sdpMid": "0",
                                "tcpType": null,
                                "type": "host",
                                "usernameFragment": "ZAez"
                            }
                        });
                    }, 0);
                }
            });

            window.webkitRTCPeerConnection = webkitRTCPeerConnection;

            window.URL.createObjectURL = function (url) {
                debugger
                return 'blob:chrome://new-tab-page/' + randomUUID();
            };
            window.URL.revokeObjectURL = function (objectURL) {
            };
            const oriMessageEvent = window.MessageEvent;

            class MessageEvent extends oriMessageEvent {
                constructor(props) {
                    super(props);
                    if (props instanceof Object) {
                        const event = this;
                        Object.keys(props).forEach(function (key) {
                            Object.defineProperty(event, key, {
                                get: function () {
                                    return props[key];
                                }
                            });
                        })
                    }

                }


            }

            function contextifyObj(obj) {
                if (vm.isContext(obj)) {
                    return;
                }

                vm.createContext(obj);
            }

            window.MessageEvent = MessageEvent;

            class MyWindow {
            }

            class Worker extends window.EventTarget {
                constructor(...args) {
                    super(...args);
                    if (args[0] instanceof window.Blob && args[0].type.indexOf('javascript') !== -1) {
                        const worker = this;
                        const newWindow = new MyWindow();
                        worker.newWindow = newWindow;
                        Object.assign(newWindow, window, global);
                        newWindow.postMessage = function (data) {
                            // 定义子线程的postMessage
                            const event = new window.MessageEvent({data: data, currentTarget: this});
                            // 主线程通过worker.onmessage指定监听函数，接收子线程发回来的消息。
                            worker.onmessage.call(worker, event);
                        };
                        let newWindowOnmessage;
                        Object.defineProperty(newWindow, 'onmessage', {
                            get: function () {
                                return newWindowOnmessage;
                            },
                            set: function (value) {
                                return newWindowOnmessage = value;
                            }
                        })
                        const reader = new window.FileReader();
                        reader.addEventListener('loadend', (e) => {
                            worker.jsCode = e.target.result;
                            // worker.jsCode = '(function(){debugger; var workerData = {p: navigator.platform,l: navigator.languages, hwC: navigator.hardwareConcurrency, dM: navigator.deviceMemory, wd: navigator.webdriver, uA: navigator.userAgent };postMessage(workerData);})()'
                            // worker.jsCode = worker.jsCode.replace('~function(Q,h,i){onmessage=(', '~function(Q,h,i){onmessage=(debugger;');
                            contextifyObj(newWindow);
                            vm.runInContext(worker.jsCode, newWindow);
                            // window.Function(this.jsCode)();
                        });
                        reader.readAsText(args[0]);
                    }

                }

                postMessage(data) {
                    // 主线程通过postMessage向子线程发送消息, 子线程的onmessage函数接收并执行。
                    const event = new window.MessageEvent({data: data, currentTarget: this});
                    const worker = this;
                    setTimeout(function () {
                        worker.newWindow.onmessage.call(window, event);
                    }, 100);
                }

                onerror() {
                }

                onmessageerror() {
                }

                terminate() {
                }
            }

            window.Worker = Worker;

            window.isSecureContext = true;
            window.offscreenBuffering = true;
            window.closed = false;
            window.crossOriginIsolated = false;
            window.originAgentCluster = false;
            // delete window._runScripts;
            window.document.adoptedStyleSheets = [];
            window.document.fullscreen = false;
            window.document.fullscreenEnabled = false;
            window.document.wasDiscarded = false;
            window.document.webkitFullscreenEnabled = false;
            window.document.webkitHidden = false;
            window.document.webkitIsFullScreen = false;
            window.document.xmlStandalone = false;
            window.document.webkitVisibilityState = "visible";
            window.document.domain = window.location.host;

            // let currentScript = null;
            // Object.defineProperty(window.document, 'currentScript', {
            //     configurable: true,
            //     enumerable: true,
            //     get: function () {
            //         return currentScript;
            //     },
            //     set: function (value) {
            //         currentScript = value;
            //     }
            // });


            window.Window.prototype = window.Object.getPrototypeOf(window);
            const oriGetOwnPropertyDescriptors = window.Object.getOwnPropertyDescriptors;
            window.Object.getOwnPropertyDescriptors = function getOwnPropertyDescriptors(...args) {
                // if (args[0] === navigator) {
                //     return {};
                // } else if (args[0] === screen) {
                //     return {};
                // }
                return oriGetOwnPropertyDescriptors(...args);
            }

            const oriGetOwnPropertyDescriptor = window.Object.getOwnPropertyDescriptor;
            window.Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(...args) {
                const args0String = args[0].toString();
                if (args[0] === navigator) {
                    return undefined;
                } else if (args[0] === screen) {
                    return undefined;
                } else if (args0String === '[object HTMLIFrameElement]' && args[1] === 'loading') {
                    return {
                        configurable: true,
                        enumerable: true
                    }
                } else if (args0String === '[object Window]') {
                    const descriptor = {
                        get: function get() {
                        },
                        set: function set() {
                        },
                        enumerable: true,
                        configurable: true,
                    };
                    Object.defineProperty(descriptor.get, 'name', {
                        enumerable: true,
                        configurable: true,
                        get() {
                            return 'get window';
                        }
                    })
                    Object.defineProperty(descriptor.set, 'name', {
                        enumerable: true,
                        configurable: true,
                        get() {
                            return 'set window';
                        }
                    })
                    return descriptor;
                }
                return oriGetOwnPropertyDescriptor(...args);
            }
            window.HTMLAudioElement.prototype.canPlayType = function (...args) {
                if (args[0] && typeof args[0] === 'string') {
                    if (args[0].startsWith('audio/x-m4a')) {
                        return 'maybe';
                    }
                    return 'probably';
                }
                return '';
            }
            // const oriCanPlayType = window.HTMLAudioElement.prototype.canPlayType;
            window.HTMLVideoElement.prototype.canPlayType = function (...args) {
                if (args[0] && typeof args[0] === 'string') {
                    if (args[0].startsWith('audio/x-m4a')) {
                        return 'maybe';
                    }
                    return 'probably';
                }
                return '';
            }
            const origetOwnPropertyNames = window.Object.getOwnPropertyNames;
            window.Object.getOwnPropertyNames = function getOwnPropertyNames(...args) {
                const args0String = args[0].toString();
                if (args0String === '[object Window]') {
                    return JSON.parse('["0","Object","Function","Array","Number","parseFloat","parseInt","Infinity","NaN","undefined","Boolean","String","Symbol","Date","Promise","RegExp","Error","AggregateError","EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError","globalThis","JSON","Math","Intl","ArrayBuffer","Uint8Array","Int8Array","Uint16Array","Int16Array","Uint32Array","Int32Array","Float32Array","Float64Array","Uint8ClampedArray","BigUint64Array","BigInt64Array","DataView","Map","BigInt","Set","WeakMap","WeakSet","Proxy","Reflect","FinalizationRegistry","WeakRef","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape","eval","isFinite","isNaN","console","Option","Image","Audio","webkitURL","webkitRTCPeerConnection","webkitMediaStream","WebKitMutationObserver","WebKitCSSMatrix","XSLTProcessor","XPathResult","XPathExpression","XPathEvaluator","XMLSerializer","XMLHttpRequestUpload","XMLHttpRequestEventTarget","XMLHttpRequest","XMLDocument","WritableStreamDefaultWriter","WritableStreamDefaultController","WritableStream","Worker","Window","WheelEvent","WebSocket","WebGLVertexArrayObject","WebGLUniformLocation","WebGLTransformFeedback","WebGLTexture","WebGLSync","WebGLShaderPrecisionFormat","WebGLShader","WebGLSampler","WebGLRenderingContext","WebGLRenderbuffer","WebGLQuery","WebGLProgram","WebGLFramebuffer","WebGLContextEvent","WebGLBuffer","WebGLActiveInfo","WebGL2RenderingContext","WaveShaperNode","VisualViewport","VirtualKeyboardGeometryChangeEvent","ValidityState","VTTCue","UserActivation","URLSearchParams","URLPattern","URL","UIEvent","TrustedTypePolicyFactory","TrustedTypePolicy","TrustedScriptURL","TrustedScript","TrustedHTML","TreeWalker","TransitionEvent","TransformStreamDefaultController","TransformStream","TrackEvent","TouchList","TouchEvent","Touch","TimeRanges","TextTrackList","TextTrackCueList","TextTrackCue","TextTrack","TextMetrics","TextEvent","TextEncoderStream","TextEncoder","TextDecoderStream","TextDecoder","Text","TaskSignal","TaskPriorityChangeEvent","TaskController","TaskAttributionTiming","SyncManager","SubmitEvent","StyleSheetList","StyleSheet","StylePropertyMapReadOnly","StylePropertyMap","StorageEvent","Storage","StereoPannerNode","StaticRange","ShadowRoot","Selection","SecurityPolicyViolationEvent","ScriptProcessorNode","ScreenOrientation","Screen","Scheduling","Scheduler","SVGViewElement","SVGUseElement","SVGUnitTypes","SVGTransformList","SVGTransform","SVGTitleElement","SVGTextPositioningElement","SVGTextPathElement","SVGTextElement","SVGTextContentElement","SVGTSpanElement","SVGSymbolElement","SVGSwitchElement","SVGStyleElement","SVGStringList","SVGStopElement","SVGSetElement","SVGScriptElement","SVGSVGElement","SVGRectElement","SVGRect","SVGRadialGradientElement","SVGPreserveAspectRatio","SVGPolylineElement","SVGPolygonElement","SVGPointList","SVGPoint","SVGPatternElement","SVGPathElement","SVGNumberList","SVGNumber","SVGMetadataElement","SVGMatrix","SVGMaskElement","SVGMarkerElement","SVGMPathElement","SVGLinearGradientElement","SVGLineElement","SVGLengthList","SVGLength","SVGImageElement","SVGGraphicsElement","SVGGradientElement","SVGGeometryElement","SVGGElement","SVGForeignObjectElement","SVGFilterElement","SVGFETurbulenceElement","SVGFETileElement","SVGFESpotLightElement","SVGFESpecularLightingElement","SVGFEPointLightElement","SVGFEOffsetElement","SVGFEMorphologyElement","SVGFEMergeNodeElement","SVGFEMergeElement","SVGFEImageElement","SVGFEGaussianBlurElement","SVGFEFuncRElement","SVGFEFuncGElement","SVGFEFuncBElement","SVGFEFuncAElement","SVGFEFloodElement","SVGFEDropShadowElement","SVGFEDistantLightElement","SVGFEDisplacementMapElement","SVGFEDiffuseLightingElement","SVGFEConvolveMatrixElement","SVGFECompositeElement","SVGFEComponentTransferElement","SVGFEColorMatrixElement","SVGFEBlendElement","SVGEllipseElement","SVGElement","SVGDescElement","SVGDefsElement","SVGComponentTransferFunctionElement","SVGClipPathElement","SVGCircleElement","SVGAnimationElement","SVGAnimatedTransformList","SVGAnimatedString","SVGAnimatedRect","SVGAnimatedPreserveAspectRatio","SVGAnimatedNumberList","SVGAnimatedNumber","SVGAnimatedLengthList","SVGAnimatedLength","SVGAnimatedInteger","SVGAnimatedEnumeration","SVGAnimatedBoolean","SVGAnimatedAngle","SVGAnimateTransformElement","SVGAnimateMotionElement","SVGAnimateElement","SVGAngle","SVGAElement","Response","ResizeObserverSize","ResizeObserverEntry","ResizeObserver","Request","ReportingObserver","ReadableStreamDefaultReader","ReadableStreamDefaultController","ReadableStreamBYOBRequest","ReadableStreamBYOBReader","ReadableStream","ReadableByteStreamController","Range","RadioNodeList","RTCTrackEvent","RTCStatsReport","RTCSessionDescription","RTCSctpTransport","RTCRtpTransceiver","RTCRtpSender","RTCRtpReceiver","RTCPeerConnectionIceEvent","RTCPeerConnectionIceErrorEvent","RTCPeerConnection","RTCIceTransport","RTCIceCandidate","RTCErrorEvent","RTCError","RTCEncodedVideoFrame","RTCEncodedAudioFrame","RTCDtlsTransport","RTCDataChannelEvent","RTCDataChannel","RTCDTMFToneChangeEvent","RTCDTMFSender","RTCCertificate","PromiseRejectionEvent","ProgressEvent","Profiler","ProcessingInstruction","PopStateEvent","PointerEvent","PluginArray","Plugin","PictureInPictureWindow","PictureInPictureEvent","PeriodicWave","PerformanceTiming","PerformanceServerTiming","PerformanceResourceTiming","PerformancePaintTiming","PerformanceObserverEntryList","PerformanceObserver","PerformanceNavigationTiming","PerformanceNavigation","PerformanceMeasure","PerformanceMark","PerformanceLongTaskTiming","PerformanceEventTiming","PerformanceEntry","PerformanceElementTiming","Performance","Path2D","PannerNode","PageTransitionEvent","OverconstrainedError","OscillatorNode","OffscreenCanvasRenderingContext2D","OffscreenCanvas","OfflineAudioContext","OfflineAudioCompletionEvent","NodeList","NodeIterator","NodeFilter","Node","NetworkInformation","Navigator","NavigationTransition","NavigationHistoryEntry","NavigationDestination","NavigationCurrentEntryChangeEvent","Navigation","NavigateEvent","NamedNodeMap","MutationRecord","MutationObserver","MutationEvent","MouseEvent","MimeTypeArray","MimeType","MessagePort","MessageEvent","MessageChannel","MediaStreamTrackProcessor","MediaStreamTrackGenerator","MediaStreamTrackEvent","MediaStreamTrack","MediaStreamEvent","MediaStreamAudioSourceNode","MediaStreamAudioDestinationNode","MediaStream","MediaRecorder","MediaQueryListEvent","MediaQueryList","MediaList","MediaError","MediaEncryptedEvent","MediaElementAudioSourceNode","MediaCapabilities","Location","LayoutShiftAttribution","LayoutShift","LargestContentfulPaint","KeyframeEffect","KeyboardEvent","IntersectionObserverEntry","IntersectionObserver","InputEvent","InputDeviceInfo","InputDeviceCapabilities","ImageData","ImageCapture","ImageBitmapRenderingContext","ImageBitmap","IdleDeadline","IIRFilterNode","IDBVersionChangeEvent","IDBTransaction","IDBRequest","IDBOpenDBRequest","IDBObjectStore","IDBKeyRange","IDBIndex","IDBFactory","IDBDatabase","IDBCursorWithValue","IDBCursor","History","Headers","HashChangeEvent","HTMLVideoElement","HTMLUnknownElement","HTMLUListElement","HTMLTrackElement","HTMLTitleElement","HTMLTimeElement","HTMLTextAreaElement","HTMLTemplateElement","HTMLTableSectionElement","HTMLTableRowElement","HTMLTableElement","HTMLTableColElement","HTMLTableCellElement","HTMLTableCaptionElement","HTMLStyleElement","HTMLSpanElement","HTMLSourceElement","HTMLSlotElement","HTMLSelectElement","HTMLScriptElement","HTMLQuoteElement","HTMLProgressElement","HTMLPreElement","HTMLPictureElement","HTMLParamElement","HTMLParagraphElement","HTMLOutputElement","HTMLOptionsCollection","HTMLOptionElement","HTMLOptGroupElement","HTMLObjectElement","HTMLOListElement","HTMLModElement","HTMLMeterElement","HTMLMetaElement","HTMLMenuElement","HTMLMediaElement","HTMLMarqueeElement","HTMLMapElement","HTMLLinkElement","HTMLLegendElement","HTMLLabelElement","HTMLLIElement","HTMLInputElement","HTMLImageElement","HTMLIFrameElement","HTMLHtmlElement","HTMLHeadingElement","HTMLHeadElement","HTMLHRElement","HTMLFrameSetElement","HTMLFrameElement","HTMLFormElement","HTMLFormControlsCollection","HTMLFontElement","HTMLFieldSetElement","HTMLEmbedElement","HTMLElement","HTMLDocument","HTMLDivElement","HTMLDirectoryElement","HTMLDialogElement","HTMLDetailsElement","HTMLDataListElement","HTMLDataElement","HTMLDListElement","HTMLCollection","HTMLCanvasElement","HTMLButtonElement","HTMLBodyElement","HTMLBaseElement","HTMLBRElement","HTMLAudioElement","HTMLAreaElement","HTMLAnchorElement","HTMLAllCollection","GeolocationPositionError","GeolocationPosition","GeolocationCoordinates","Geolocation","GamepadHapticActuator","GamepadEvent","GamepadButton","Gamepad","GainNode","FormDataEvent","FormData","FontFaceSetLoadEvent","FontFace","FocusEvent","FileReader","FileList","File","FeaturePolicy","External","EventTarget","EventSource","EventCounts","Event","ErrorEvent","ElementInternals","Element","DynamicsCompressorNode","DragEvent","DocumentType","DocumentFragment","Document","DelayNode","DecompressionStream","DataTransferItemList","DataTransferItem","DataTransfer","DOMTokenList","DOMStringMap","DOMStringList","DOMRectReadOnly","DOMRectList","DOMRect","DOMQuad","DOMPointReadOnly","DOMPoint","DOMParser","DOMMatrixReadOnly","DOMMatrix","DOMImplementation","DOMException","DOMError","CustomStateSet","CustomEvent","CustomElementRegistry","Crypto","CountQueuingStrategy","ConvolverNode","ConstantSourceNode","CompressionStream","CompositionEvent","Comment","CloseEvent","ClipboardEvent","CharacterData","ChannelSplitterNode","ChannelMergerNode","CanvasRenderingContext2D","CanvasPattern","CanvasGradient","CanvasFilter","CanvasCaptureMediaStreamTrack","CSSVariableReferenceValue","CSSUnparsedValue","CSSUnitValue","CSSTranslate","CSSTransformValue","CSSTransformComponent","CSSSupportsRule","CSSStyleValue","CSSStyleSheet","CSSStyleRule","CSSStyleDeclaration","CSSSkewY","CSSSkewX","CSSSkew","CSSScale","CSSRuleList","CSSRule","CSSRotate","CSSPropertyRule","CSSPositionValue","CSSPerspective","CSSPageRule","CSSNumericValue","CSSNumericArray","CSSNamespaceRule","CSSMediaRule","CSSMatrixComponent","CSSMathValue","CSSMathSum","CSSMathProduct","CSSMathNegate","CSSMathMin","CSSMathMax","CSSMathInvert","CSSMathClamp","CSSLayerStatementRule","CSSLayerBlockRule","CSSKeywordValue","CSSKeyframesRule","CSSKeyframeRule","CSSImportRule","CSSImageValue","CSSGroupingRule","CSSFontPaletteValuesRule","CSSFontFaceRule","CSSCounterStyleRule","CSSContainerRule","CSSConditionRule","CSS","CDATASection","ByteLengthQueuingStrategy","BroadcastChannel","BlobEvent","Blob","BiquadFilterNode","BeforeUnloadEvent","BeforeInstallPromptEvent","BaseAudioContext","BarProp","AudioWorkletNode","AudioSinkInfo","AudioScheduledSourceNode","AudioProcessingEvent","AudioParamMap","AudioParam","AudioNode","AudioListener","AudioDestinationNode","AudioContext","AudioBufferSourceNode","AudioBuffer","Attr","AnimationEvent","AnimationEffect","Animation","AnalyserNode","AbstractRange","AbortSignal","AbortController","window","self","document","name","location","customElements","history","navigation","locationbar","menubar","personalbar","scrollbars","statusbar","toolbar","status","closed","frames","length","top","opener","parent","frameElement","navigator","origin","external","screen","innerWidth","innerHeight","scrollX","pageXOffset","scrollY","pageYOffset","visualViewport","screenX","screenY","outerWidth","outerHeight","devicePixelRatio","event","clientInformation","offscreenBuffering","screenLeft","screenTop","styleMedia","onsearch","isSecureContext","trustedTypes","performance","onappinstalled","onbeforeinstallprompt","crypto","indexedDB","sessionStorage","localStorage","onbeforexrselect","onabort","onbeforeinput","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextlost","oncontextmenu","oncontextrestored","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onpause","onplay","onplaying","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel","onauxclick","ongotpointercapture","onlostpointercapture","onpointerdown","onpointermove","onpointerrawupdate","onpointerup","onpointercancel","onpointerover","onpointerout","onpointerenter","onpointerleave","onselectstart","onselectionchange","onanimationend","onanimationiteration","onanimationstart","ontransitionrun","ontransitionstart","ontransitionend","ontransitioncancel","onafterprint","onbeforeprint","onbeforeunload","onhashchange","onlanguagechange","onmessage","onmessageerror","onoffline","ononline","onpagehide","onpageshow","onpopstate","onrejectionhandled","onstorage","onunhandledrejection","onunload","crossOriginIsolated","scheduler","alert","atob","blur","btoa","cancelAnimationFrame","cancelIdleCallback","captureEvents","clearInterval","clearTimeout","close","confirm","createImageBitmap","fetch","find","focus","getComputedStyle","getSelection","matchMedia","moveBy","moveTo","open","postMessage","print","prompt","queueMicrotask","releaseEvents","reportError","requestAnimationFrame","requestIdleCallback","resizeBy","resizeTo","scroll","scrollBy","scrollTo","setInterval","setTimeout","stop","structuredClone","webkitCancelAnimationFrame","webkitRequestAnimationFrame","Atomics","chrome","WebAssembly","credentialless","caches","cookieStore","ondevicemotion","ondeviceorientation","ondeviceorientationabsolute","launchQueue","onbeforematch","AbsoluteOrientationSensor","Accelerometer","AudioWorklet","BatteryManager","Cache","CacheStorage","Clipboard","ClipboardItem","CookieChangeEvent","CookieStore","CookieStoreManager","Credential","CredentialsContainer","CryptoKey","DeviceMotionEvent","DeviceMotionEventAcceleration","DeviceMotionEventRotationRate","DeviceOrientationEvent","FederatedCredential","GravitySensor","Gyroscope","Keyboard","KeyboardLayoutMap","LinearAccelerationSensor","Lock","LockManager","MIDIAccess","MIDIConnectionEvent","MIDIInput","MIDIInputMap","MIDIMessageEvent","MIDIOutput","MIDIOutputMap","MIDIPort","MediaDeviceInfo","MediaDevices","MediaKeyMessageEvent","MediaKeySession","MediaKeyStatusMap","MediaKeySystemAccess","MediaKeys","NavigationPreloadManager","NavigatorManagedData","OrientationSensor","PasswordCredential","RelativeOrientationSensor","Sanitizer","ScreenDetailed","ScreenDetails","Sensor","SensorErrorEvent","ServiceWorker","ServiceWorkerContainer","ServiceWorkerRegistration","StorageManager","SubtleCrypto","VirtualKeyboard","WebTransport","WebTransportBidirectionalStream","WebTransportDatagramDuplexStream","WebTransportError","Worklet","XRDOMOverlayState","XRLayer","XRWebGLBinding","AudioData","EncodedAudioChunk","EncodedVideoChunk","ImageTrack","ImageTrackList","VideoColorSpace","VideoFrame","AudioDecoder","AudioEncoder","ImageDecoder","VideoDecoder","VideoEncoder","AuthenticatorAssertionResponse","AuthenticatorAttestationResponse","AuthenticatorResponse","PublicKeyCredential","BarcodeDetector","Bluetooth","BluetoothCharacteristicProperties","BluetoothDevice","BluetoothRemoteGATTCharacteristic","BluetoothRemoteGATTDescriptor","BluetoothRemoteGATTServer","BluetoothRemoteGATTService","CaptureController","EyeDropper","FileSystemDirectoryHandle","FileSystemFileHandle","FileSystemHandle","FileSystemWritableFileStream","FontData","FragmentDirective","HID","HIDConnectionEvent","HIDDevice","HIDInputReportEvent","IdentityCredential","IdleDetector","LaunchParams","LaunchQueue","OTPCredential","PaymentAddress","PaymentRequest","PaymentResponse","PaymentMethodChangeEvent","Presentation","PresentationAvailability","PresentationConnection","PresentationConnectionAvailableEvent","PresentationConnectionCloseEvent","PresentationConnectionList","PresentationReceiver","PresentationRequest","Serial","SerialPort","USB","USBAlternateInterface","USBConfiguration","USBConnectionEvent","USBDevice","USBEndpoint","USBInTransferResult","USBInterface","USBIsochronousInTransferPacket","USBIsochronousInTransferResult","USBIsochronousOutTransferPacket","USBIsochronousOutTransferResult","USBOutTransferResult","WakeLock","WakeLockSentinel","WindowControlsOverlay","WindowControlsOverlayGeometryChangeEvent","XRAnchor","XRAnchorSet","XRBoundedReferenceSpace","XRCPUDepthInformation","XRCamera","XRDepthInformation","XRFrame","XRHitTestResult","XRHitTestSource","XRInputSource","XRInputSourceArray","XRInputSourceEvent","XRInputSourcesChangeEvent","XRLightEstimate","XRLightProbe","XRPose","XRRay","XRReferenceSpace","XRReferenceSpaceEvent","XRRenderState","XRRigidTransform","XRSession","XRSessionEvent","XRSpace","XRSystem","XRTransientInputHitTestResult","XRTransientInputHitTestSource","XRView","XRViewerPose","XRViewport","XRWebGLDepthInformation","XRWebGLLayer","getScreenDetails","queryLocalFonts","showDirectoryPicker","showOpenFilePicker","showSaveFilePicker","originAgentCluster","speechSynthesis","oncontentvisibilityautostatechange","AnimationPlaybackEvent","AnimationTimeline","CSSAnimation","CSSTransition","DocumentTimeline","BackgroundFetchManager","BackgroundFetchRecord","BackgroundFetchRegistration","BluetoothUUID","BrowserCaptureMediaStreamTrack","CropTarget","ContentVisibilityAutoStateChangeEvent","DelegatedInkTrailPresenter","Ink","Highlight","HighlightRegistry","MathMLElement","MediaMetadata","MediaSession","MediaSource","SourceBuffer","SourceBufferList","MediaSourceHandle","NavigatorUAData","Notification","PaymentManager","PaymentRequestUpdateEvent","PeriodicSyncManager","PermissionStatus","Permissions","PushManager","PushSubscription","PushSubscriptionOptions","RemotePlayback","SharedWorker","SpeechSynthesisErrorEvent","SpeechSynthesisEvent","SpeechSynthesisUtterance","VideoPlaybackQuality","ViewTransition","webkitSpeechGrammar","webkitSpeechGrammarList","webkitSpeechRecognition","webkitSpeechRecognitionError","webkitSpeechRecognitionEvent","openDatabase","webkitRequestFileSystem","webkitResolveLocalFileSystemURL","define","ethereum","web3","isSpa","onProtectionInitialized","reeseSkipExpirationCheck","scriptElement","showBlockPage","a1_0x4f53","a1_0x5904","reese84","reese84interrogator","initializeProtection","protectionSubmitCaptcha","protectionLoaded"]');
                } else if (args0String === window.navigator) {
                    return [];
                } else if (args0String === window.document) {
                    return ["location"];
                }
                const result = origetOwnPropertyNames(...args);
                if (args[0].name && ['getDetails', 'getIsInstalled', 'installState', 'runningState'].includes(args[0].name)) {
                    for (let i = 0; i < result.length; i++) {
                        if (result[i] === 'prototype') {
                            result.splice(i, 1);
                            break;
                        }
                    }
                }
                return result;
            }

            window.console = console;
            const origetPrototypeOf = window.Object.getPrototypeOf;
            const prototypeOfWindow = window.Object.getPrototypeOf(window);
            prototypeOfWindow.TEMPORARY = 0;
            prototypeOfWindow.PERSISTENT = 1;
            window.Object.getPrototypeOf = function (obj) {
                if (obj === window) {
                    // return {"TEMPORARY": 0, "PERSISTENT": 1};
                } else if (obj === window.navigator) {
                } else if (obj === window.document) {
                }
                // console.log(`call origetPrototypeOf : ${obj}`);
                return origetPrototypeOf(obj);
            }

            const oriTest = RegExp.prototype.test;
            RegExp.prototype.test = function (...args) {
                if (this.toString().indexOf('native code') !== -1) {
                    return true;
                }
                return oriTest.call(this, ...args);
            }
            window.exitPointerLock = function (...args) {
            }
            window.showOpenFilePicker = function (...args) {
            }
            window.webkitSpeechGrammar = function (...args) {
            }
            if (!global.document) {
                global.window = window;
                global.self = window;
                global.Object = window.Object;
                global.document = window.document;
                global.screen = window.screen;
                global.navigator = window.navigator;
                global.Node = window.Node;
                global.Window = window.Window;
                global.location = window.location;
                global.performance = window.performance;
                global.WebGLRenderingContext = window.WebGLRenderingContext;
                global.CanvasRenderingContext2D = window.CanvasRenderingContext2D;
                global.HTMLCanvasElement = window.HTMLCanvasElement;
                global.jsengineTimeoutList = this.jsengineTimeoutList;
                global.jsengineIntervalList = this.jsengineIntervalList;
                global.jsengineEventList = this.jsengineEventList;
                global.addEventListener = window.addEventListener;
                global.Location = window.Location;
                global.HTMLCanvasElement = window.HTMLCanvasElement;
                global.DOMStringList = window.DOMStringList;
                global.HTMLAudioElement = window.HTMLAudioElement;
                global.HTMLVideoElement = window.HTMLVideoElement;
                global.HTMLIFrameElement = window.HTMLIFrameElement;
                global.getComputedStyle = window.getComputedStyle;
                global.RTCPeerConnection = window.RTCPeerConnection;
                global.indexedDB = window.indexedDB;
                global.openDatabase = window.openDatabase
                global.speechSynthesis = window.speechSynthesis;
                global.DeviceOrientationEvent = window.DeviceOrientationEvent;
                global.DeviceMotionEvent = window.DeviceMotionEvent;
                global.PointerEvent = window.PointerEvent;
                global.AudioContext = window.AudioContext;
                global.Notification = window.Notification;
                global.CSSStyleDeclaration = window.CSSStyleDeclaration;
                global.matchMedia = window.matchMedia;
                global.Element = window.Element;
                global.AudioParam = window.AudioParam;
                global.OscillatorNode = window.OscillatorNode;
                global.DynamicsCompressorNode = window.DynamicsCompressorNode;
                global.OfflineAudioCompletionEvent = window.OfflineAudioCompletionEvent;
                global.AudioBuffer = window.AudioBuffer;
                global.OfflineAudioContext = window.OfflineAudioContext;
                global.SpeechSynthesis = window.SpeechSynthesis;
                global.history = window.history;
                global.localStorage = window.localStorage;
                global.Image = window.Image;
                global.sessionStorage = window.sessionStorage;
                global.Worker = window.Worker;
                global.postMessage = window.postMessage;
                global.XMLHttpRequest = window.XMLHttpRequest;
                global.devicePixelRatio = window.devicePixelRatio;
                global.WebGLShader = window.WebGLShader;
                global.WebGLProgram = window.WebGLProgram;
                global.WebGLBuffer = window.WebGLBuffer;
            }

            function initIframe(ele, windowManager, needApp = null) {
                if (needApp === null) {
                    let needApp = false;
                    if (ele.createByIframe) {
                        needApp = true;
                    }
                    if (ele.myIframeinit) {
                        return;
                    }
                }
                windowManager.htmlText = '';
                windowManager.jsdomOptions.runScripts = 'outside-only';
                const contentWindow = windowManager.initWindow();
                const contentDocument = contentWindow.document;
                contentWindow.isIframe = true;
                contentDocument.isIframe = true;
                const chrome = getWindowChrome(needApp);
                Object.defineProperty(ele, 'contentWindow', {
                    configurable: true,
                    enumerable: true,
                    get: function () {
                        return contentWindow;
                    },
                });
                Object.defineProperty(contentWindow, 'chrome', {
                    configurable: true,
                    enumerable: true,
                    get: function () {
                        return chrome;
                    }
                });
                Object.defineProperty(ele, 'contentDocument', {
                    configurable: true,
                    enumerable: true,
                    get: function () {
                        return contentDocument;
                    },
                });
                ele.myIframeinit = true;
            }

            const oriCreateElement = window.document.createElement;
            window.document.createElement = function createElement(...args) {
                const ele = oriCreateElement.call(this, ...args);
                if (this.isIframe) {
                    ele.createByIframe = true;
                }
                if (args[0].toUpperCase() === 'IFRAME') {
                    // initIframe(ele, windowManager, false);
                } else if (args[0].toUpperCase() === 'SPAN') {
                    //     akamai
                    Object.defineProperty(ele, 'offsetWidth', {
                        configurable: true,
                        enumerable: true,
                        get: function () {
                            if (ele.innerHTML === 'mmmmmmmmlli') {
                                if (ele.style._values && ele.style._values['font-family'] === 'Monospace') {
                                    return 1267;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Wingdings 2') {
                                    return 1267;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'ITC Bodoni 72 Bold') {
                                    return 1267;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Menlo') {
                                    return 1272;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Gill Sans MT') {
                                    return 1453;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Lucida Sans') {
                                    return 1453;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Bodoni 72') {
                                    return 1453;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Serif') {
                                    return 1362;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Shree Devanagari 714') {
                                    return 1362;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Microsoft Tai Le') {
                                    return 1453;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Nimbus Roman No 9 L') {
                                    return 1453;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Candara') {
                                    return 1453;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Press Start 2P') {
                                    return 1453;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Waseem') {
                                    return 1453;
                                }


                            }
                            return 0;
                        }
                    });
                    Object.defineProperty(ele, 'offsetHeight', {
                        configurable: true,
                        enumerable: true,
                        get: function () {
                            if (ele.innerHTML === 'mmmmmmmmlli') {
                                if (ele.style._values && ele.style._values['font-family'] === 'Monospace') {
                                    return 222;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Wingdings 2') {
                                    return 222
                                } else if (ele.style._values && ele.style._values['font-family'] === 'ITC Bodoni 72 Bold') {
                                    return 222;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Menlo') {
                                    return 224;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Gill Sans MT') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Lucida Sans') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Bodoni 72') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Serif') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Shree Devanagari 714') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Microsoft Tai Le') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Nimbus Roman No 9 L') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Candara') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Press Start 2P') {
                                    return 269;
                                } else if (ele.style._values && ele.style._values['font-family'] === 'Waseem') {
                                    return 278;
                                }
                            }
                            return 0;
                        }
                    });
                }
                return ele
            }

            const oriQuerySelector = window.HTMLElement.prototype.querySelector;
            window.HTMLElement.prototype.querySelector = function (...args) {
                const ele = oriQuerySelector.call(this, ...args);
                if (ele instanceof window.HTMLIFrameElement && !ele.contentWindow.chrome) {
                    initIframe(ele, windowManager);
                }
                return ele;
            }

            class VisualViewport {
                constructor() {
                    this.width = window.innerWidth;
                    this.height = window.innerHeight;
                    this.scale = 1;
                    this.offsetLeft = 0;
                    this.offsetTop = 0;
                    this.onresize = null;
                    this.onscroll = null;
                    this.pageLeft = 0;
                    this.pageTop = 0;
                }
            }

            window.visualViewport = new VisualViewport();
            window.PerformanceObserver = function () {
            }
            window.PerformanceObserver.supportedEntryTypes = ["element", "event", "first-input", "largest-contentful-paint", "layout-shift", "longtask", "mark", "measure", "navigation", "paint", "resource"];


            window.onbeforeinstallprompt = function () {
            }

            // JSON.stringify(window["Object"]["getOwnPropertyDescriptor"](window, "onbeforeinstallprompt"))

            const oriAppendChild = window.HTMLElement.prototype.appendChild;
            window.HTMLElement.prototype.appendChild = function (child) {
                const result = oriAppendChild.call(this, child);
                if (child instanceof window.HTMLIFrameElement) {
                    initIframe(child, windowManager, false);
                }
                return result;
            }

            const oriInsertBefore = window.Element.prototype.insertBefore;
            window.Element.prototype.insertBefore = function (node, child) {
                const result = oriInsertBefore.call(this, node, child);
                if (node instanceof window.HTMLIFrameElement) {
                    initIframe(node, windowManager, true);
                }
                return result;
            }

            const oriCreateHTMLDocument = window.document.implementation.createHTMLDocument;
            window.document.implementation.createHTMLDocument = function (...args) {
                const result = oriCreateHTMLDocument.call(this, ...args);
                result.createElement = window.document.createElement;
                // 粗暴修改, 可能会报错
                // return window.document;
                return result;
            }

            class DocumentTimeline {
                constructor() {
                    this.currentTime = 54943.297 + randomNum(1000, 20000);
                }
            }

            const documentTimeline = new DocumentTimeline();
            const documentTimelineNow = window.Date.now();
            window.DocumentTimeline = function () {
                const theSt = documentTimeline.currentTime + window.Date.now() - documentTimelineNow;
                documentTimeline.currentTime = Math.floor(theSt * 1000) / 1000;
                return documentTimeline;
            }

            const oriMeasureText = window.CanvasRenderingContext2D.prototype.measureText;
            if (oriMeasureText.toString() === 'function measureText() { [native code] }') {
                window.CanvasRenderingContext2D.prototype.measureText = function (text) {
                    // reese84
                    const result = oriMeasureText.call(this, text);
                    const bypassFont = ['ArialUnicodeMS', 'GillSans', 'HelveticaNeue'];
                    if (text === 'mmmmmmmmlli') {
                        for (let i = 0; i < bypassFont.length; i++) {
                            if (this.font.endsWith('monospace') && this.font.includes(bypassFont[i])) {
                                result.width += 52.5234375;
                                break;
                            }
                        }
                    }
                    return result;
                }
            }
            const navigatorMimeTypes = {};
            const navigatorPlugin = createPdfPlugin("PDF Viewer");
            navigatorMimeTypes[0] = navigatorPlugin[0];
            navigatorMimeTypes[1] = navigatorPlugin[1];
            navigatorMimeTypes['application/pdf'] = navigatorMimeTypes[0];
            navigatorMimeTypes['text/pdf'] = navigatorMimeTypes[1];
            navigatorMimeTypes.length = 2;
            window.navigator.__proto__.mimeTypes = navigatorMimeTypes;
            window.screenX = randomNum(126, 1000);
            window.screenY = randomNum(126, 400);
            if (this.windowConfigFunction) {
                this.windowConfigFunction(window, this.ua, this.referer, this.traceId, this.productName);
            }
            global.windowIsConfig = true;
            window.reeseSkipExpirationCheck = true;
            window.constructor.toString = function () {
                return 'function Window() { [native code] }'
            };

            Object.defineProperty(window.MouseEvent.prototype, 'movementX', {
                configurable:true, enumerable: true,
                get: function (){
                    return this.movementX;
                },
                set: function (value) {
                    this.movementX = value;
                }
            })

            window.navigator.__proto__.userAgentData = {
                "brands": [{
                    "brand": "Chromium",
                    "version": "112"
                }, {"brand": "Google Chrome", "version": "112"}, {"brand": "Not:A-Brand", "version": "99"}],
                "mobile": false,
                "platform": "macOS"
            };
            window.screenTop = -32;
            window.screenLeft = 0;
        }

        Object.assign(jsdomOptions, this.jsdomOptions)
        global.windowIsConfig = false;
        const windowManager = this;
        if (jsdomOptions.runScripts === 'dangerously') {
            const runInContext = vm.runInContext;
            vm.runInContext = function (...args) {
                const window = args[1];
                if (window.document && window.document.body) {
                    if (!global.windowIsConfig) {
                        configWindow.apply(windowManager, [window, windowManager]);
                    }
                }
                return runInContext(...args);
            };
        }

        const dom = new JSDOM(htmlText, jsdomOptions);
        const window = dom.window;
        if (jsdomOptions.runScripts !== 'dangerously') {
            configWindow.apply(this, [window, windowManager]);
        }
        return window;
    }

    setCookieJar(window, referer) {
        let cookieJar;
        if (!global.cookieJar) {
            global.cookieJar = new jsdom.CookieJar();
            cookieJar = global.cookieJar;
        } else {
            cookieJar = global.cookieJar;
        }
        const oriCookie = window.document.cookie;
        const productName = this.productName;
        const traceId = this.traceId;

        Object.defineProperty(window.document, 'cookie', {
            configurable: true,
            get: function () {
                return cookieJar.getCookieStringSync(referer);
            },
            set: function (value) {
                try {
                    cookieJar.setCookieSync(value, referer);
                }catch (e) {
                    log.warn(`[${productName}][%s] setCookieSync failed: `, traceId, value);
                }

                // value = value.split(';')[0].split('=');
                // if (value[1]) {
                //     if (value[0] === 'ctt_june') {
                //         // debugger
                //         // console.log(JSON.stringify(myCookieDict));
                //         // window.clearIntervalTimeout();
                //     }
                // }
            }
        })
        if (oriCookie) {
            window.document.cookie = oriCookie;
        }
    }
    initEnv() {
        // const windowManager = this;
        global.window = this.initWindow();
        window.Object['getOwnPropertyDescriptors'](window.navigator)
        this.window = window;
        this.document = window.document;
    }
}

module.exports = {
    ResourceLoader: ResourceLoader,
    WindowManager: WindowManager,
    CookieJar: jsdom.CookieJar,
    randomNum: randomNum,
    formateArg: formateArg
}